Wireless UART (Serial) for STM32/Arduino (HM-10)

A guide to get wirless using UART communication using 2 HM-10 BLE modules.

Initially I tried going the HC-05 route to get wireless UART communication on my projects, however I always ran into connection/powering issues with the HC-05.

Recently I got the HM-10 bluetooth modules, which have worked much better for me. However one downside, compared to the HC-05, is that you will need 2 HM-10 modules and a Serial to USB cable in order to get wireless UART working.

Parts:

2x HM-10 Modules (DSD TECH HM-10 from Amazon)

1x USB to TTL Serial Cable or Adapter

Wiring Looks Like this:

MCU UART <—> HM-10 <***Wireless***> HM-10 <—> USB Serial Cable <—> Laptop

Configuring The HM-10’s

The HM-10 is configured by sending AT commands over UART. I found this accurately documents the AT commands

1. Connect the HM10 to your serial cable

Serial Cable    HM10
       TX--——-—-RX
       RX—---—-—TX
       VCC-————VCC
       GND—————GND

2. Choose a Serial monitor

Use a Serial monitor(Like Arduino’s, Minicom, PuTTY, etc..) to send AT commands. The HM-10 expects the characters(UART frames) that make up the AT command to be sent consecutively. If there is too long of a delay between characters, the HM-10 will ignore the AT command. Some serial monitors, like minicom, send characters as they are typed, which will cause the AT commands be ignored, since there will be too much delay between when the HM-10 receives each character. A work around for this is to type the AT command somewhere else, and then copy and paste it into minicom.

I usually use Arduino serial monitor, but if I need to modify parity or stop bits I’ll switch to minicom since arduino doesn’t support modifying those parameters.

Choose 9600 baud as that is the default baudrate of the modules

3. Pairing

With your first HM-10, put it into slave mode by sending the following AT command: AT+ROLE0

You can check that it was set by sending: AT+ROLE?

Connect the other HM-10, put it into master mode by sending: AT+ROLE1

While keeping the Master powered, power up the Slave module. The led on both of the hm-10s should stop blinking, which means they are paired. For this step I turn off the bluetooth on my phone and laptop, and go outside to avoid interfereance.

Once they are paired, connect the slave HM-10 to the UART port on your project, and connect the master HM-10 to the serial cable plugged into your computer. Now when the MCU transmitts a UART message, the slave HM-10 will forward it to the master HM-10 will send it to the serial monitor on the computer. When the serial monitor on the computer transmits a UART message, the master HM-10 will forward it to the slave HM-10, which will send ti to the MCU.

4. Configuration

You can configure parameters like the baud rate, parity, and stop bits. This datasheet accurately documents the AT commands and parameters.

For example, changing the baud rate to 115200 can be done with AT+BAUD4

Check if the baud rate was set by sending AT+BAUD?

When changing settings like, Baudrate, Stop bits, parity, etc.. be sure to write them down. If you forget the baudrate/party/stop bits the HM-10 is configured to, you will have to guess and check each possible combination in order to talk with it again.

If you ever want to factory reset the HM-10, send AT+RENEW

Tips

On my projects I like to add male headers so I can connect a USB to Serial cable and I also add a female header right next to it so I can slot in a HM-10 module. This gives me the flexability to use a standard USB to Serial cable or a HM-10 for print debugging/logging.

Refrences

Video: https://youtu.be/itGgUTPLkz8

HM-10s: https://www.amazon.com/DSD-TECH-Bluetooth-iBeacon-Arduino/dp/B06WGZB2N4