HM-10 Bluetooth Module
This module is equipped with Bluetooth functionality.
It can also be used as a beacon.
Specifications
- Operating Voltage: 5V
- Bluetooth Version: 4.0
- Default Name: HMSoft
- Default Baud Rate (Serial Connection): 9600
Required Hardware
- HM-10
- Arduino UNO
- UNO Cable
- F-M Cable (4 pieces)
Connection
TXD and RXD can be connected to any digital pin on the UNO board as desired (in this text, D6 and D7 are used).
HM-10 | Arduino Uno |
---|---|
GND | GND |
VCC | 5V |
TXD | D6 |
RXD | D7 |
Library
SoftwareSerial (default library)
AT Command
- The Bluetooth status can be checked using AT commands.
- AT commands can be sent via the Serial Monitor.
- The datasheet describes the AT commands available (different from those of the HC-06 Bluetooth module). Refer to the HM-10 Datasheet.
Example Code
// Include the library for serial communication
#include <SoftwareSerial.h>
// Create a SoftwareSerial object for Bluetooth communication
SoftwareSerial BTSerial(6, 7);
void setup()
{
// Set baud rate
Serial.begin(9600);
BTSerial.begin(9600);
Serial.println("Serial communication started");
}
void loop()
{
// If data is received from the Bluetooth serial, print it to the Serial Monitor
while (BTSerial.available() > 0)
{
byte data = BTSerial.read();
Serial.write(data);
}
// If data is received from the Serial Monitor, send it over Bluetooth serial
while (Serial.available() > 0)
{
byte data = Serial.read();
BTSerial.write(data);
}
}
Operation Check
After uploading the code, enter AT in the Serial Monitor to test the operation.
If OK is displayed, the module is functioning correctly.
Bluetooth Terminal Application Test
- Install a Bluetooth terminal application on your smartphone. The type of application does not matter.
- Connect to the HM-10 Bluetooth module within the application.
- Messages entered in the app will be displayed on the Serial Monitor, and vice versa, messages entered in the Serial Monitor will be displayed in the app.