Introduction: Connect HM-10 to Micro:bit Using Bluetooth

It all started when I was asked to make a automatic irrigation system. For notifying the user the microbit had to be connected to the HM-10. There was no other tutorial about how to do it, so I studied the Bluetooth connectivity and made an example in which the microbit shows a happy face when it is connected to the HM-10 and shows a sad face when it is disconnected.



1: HM-10 Bluetooth Module (Please keep in mind that other modules have not been tested)

2: Arduino UNO


Step 1: Connect the Arduino to HM-10

1. Connect 3.3V of Arduino to the VCC of HM-10.

2. Connect GND of Arduino to the GND of HM-10.

3. Connect D0 of Arduino to RX of HM-10.

4. Connect D1 of Arduino to TX of HM-10.

Step 2: Upload a Blank Sketch to Arduino

Just open Arduino IDE and upload the default sketch that opens.

Step 3: Setup HM-10

Step1: Open the serial monitor, set the line ending to "Both NL & CR", and set the baud rate to your HM-10's baud rate. The default baud rate is "115200". If the baud is correct, when you send AT, the serial monitor will send an OK back.

Step2: Send "AT+ROLE?". If it sends "OK+Get:0", then the module is in slave mode. If it sends "OK+Get:1", you can skip this part. For this project, we need to set it to the master mode. To do this type "AT+ROLE1".

Step3: Restart the HM-10 by unplugging and replugging the 3v jumper wire.

Step4:Now when we type "AT+ROLE?", it will send "OK+Get:1".

Step 4: Program the Micro:bit

For programming the Micro:bit, I will be using the block editor.

Step1: Open and create a new project.

Step2: Click the gear icon in the top right corner of the window, and in the dropdown box, click the extensions option.

Step3: In the extensions tab, search for Bluetooth service and add it.

Step4: Add the blocks as shown in the image.

Step5: Click the gear icon again, and this time click the project settings option. Here, turn on the "No pairing required" option, and click save.

Step6: Download the hex file and flash it to the micro:bit.

Step 5: Connect Micro:bit to With HM-10

Back in the Arduino Serial monitor, we have to do a few more steps to connect to the Micro:bit. At this stage, make sure that the micro:bit is turned on.

Step1: In the serial monitor send "AT+IMME1". By default, it will be 0.

Step2: Type "AT+DISC?". If that command does not work, then your HM-10 is probably in an old firmware, for such HM-10s we instead type "AT+DISI?"

Step3: The output of the serial monitor should be something like the image.

Step4: The devices shown are listed in order. For connecting to the micro:bit, you need to type "AT+CONNx". Where "x" is the number of the device which was shown earlier. For example, the first device in the order is 0, the second device is 1, the third device is 2, etc. For me, I had to type "AT+CONN0", because the micro:bit is the first device shown.

Step5: If it connects successfully, the serial monitor will send "OK+CONN", and the micro:bit will display a smiley face.

Step6: The next time you want to connect, you can just type "AT+DISC?" or "AT+DISI?", and connect with "AT+CONNx".

Step 6: Technical Details