The XY-MD02 is a wireless Bluetooth module designed for seamless communication between devices. It supports serial communication (UART) and operates using the Bluetooth 4.0 protocol, making it ideal for low-power and high-speed data transmission. This module is widely used in IoT applications, enabling microcontrollers to connect to smartphones, tablets, or other Bluetooth-enabled devices. Its compact size and ease of integration make it a popular choice for hobbyists and professionals alike.
The XY-MD02 module is designed to provide reliable and efficient Bluetooth communication. Below are its key technical specifications:
Parameter | Value |
---|---|
Bluetooth Version | 4.0 (Low Energy) |
Communication Protocol | UART (Serial Communication) |
Operating Voltage | 3.3V to 6V |
Operating Current | 8mA (typical) |
Baud Rate | 9600 bps (default, configurable) |
Transmission Range | Up to 10 meters (line of sight) |
Dimensions | 37mm x 15mm x 7mm |
Operating Temperature | -20°C to 70°C |
The XY-MD02 module has 6 pins, as described in the table below:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (3.3V to 6V). Connect to the power source. |
2 | GND | Ground. Connect to the ground of the circuit. |
3 | TXD | Transmit data pin. Sends serial data to the connected microcontroller. |
4 | RXD | Receive data pin. Receives serial data from the connected microcontroller. |
5 | EN (Key) | Enable pin. Used to switch between command and data modes. |
6 | STATE | Status indicator pin. High when connected to a device, low when disconnected. |
The XY-MD02 module is straightforward to use and can be easily integrated into a circuit. Below are the steps and best practices for using the module:
VCC
pin to a 3.3V or 5V power source and the GND
pin to the ground.TXD
pin of the module to the RX
pin of the microcontroller.RXD
pin of the module to the TX
pin of the microcontroller.EN
pin unconnected for normal operation. Pull it high to enter AT command mode.STATE
pin to an LED or microcontroller input to monitor the connection status.Below is an example of how to use the XY-MD02 module with an Arduino UNO to send and receive data via Bluetooth.
VCC
to the 5V pin on the Arduino.GND
to the GND pin on the Arduino.TXD
to pin 10 on the Arduino (software serial RX).RXD
to pin 11 on the Arduino (software serial TX).#include <SoftwareSerial.h>
// Define software serial pins for the XY-MD02 module
SoftwareSerial bluetooth(10, 11); // RX, TX
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize Bluetooth module communication
bluetooth.begin(9600); // Default baud rate for XY-MD02
Serial.println("Bluetooth module ready. Waiting for connection...");
}
void loop() {
// Check if data is available from the Bluetooth module
if (bluetooth.available()) {
char received = bluetooth.read(); // Read the incoming data
Serial.print("Received: ");
Serial.println(received); // Print the received data to the serial monitor
}
// Check if data is available from the serial monitor
if (Serial.available()) {
char toSend = Serial.read(); // Read the data from the serial monitor
bluetooth.write(toSend); // Send the data to the Bluetooth module
Serial.print("Sent: ");
Serial.println(toSend); // Print the sent data to the serial monitor
}
}
TXD
and RXD
pins.EN
pin high to enter AT command mode for configuration. Use a serial terminal to send AT commands.Module Not Responding
No Data Transmission
Unstable Connection
Cannot Enter AT Command Mode
EN
pin not pulled high.EN
pin high and reset the module to enter command mode.Q1: Can the XY-MD02 module be used with a 3.3V microcontroller?
A1: Yes, the module supports 3.3V operation. However, ensure proper voltage level shifting for the TXD
and RXD
pins if needed.
Q2: How do I reset the module to factory settings?
A2: Enter AT command mode and send the AT+RESET
command to reset the module.
Q3: What is the maximum data rate supported by the module?
A3: The module supports a maximum baud rate of 115200 bps, configurable via AT commands.
Q4: Can I use the module for audio transmission?
A4: No, the XY-MD02 is designed for data transmission only and does not support audio profiles.
By following this documentation, you can effectively integrate and use the XY-MD02 Bluetooth module in your projects.