How to Use HM-10 BLE Module With Arduino and Control a LED With It

Introduction: How to Use HM-10 BLE Module With Arduino and Control a LED With It

Hi Guys in this instructables we will learn how to use HM-10 BLE module with Arduino and we will control the LED with this HM-10 BLE module using an Android app with our Android smartphone.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Things You Need

For this instructables we will need following things :

Arduino UNO
HM10 Bluetooth Module
Resistors(1 kΩ, 470 Ω)
Jumper Wires
LED
BREADBOARD

Step 2: Schmatics

The schmatics is very simple, just connect the HM-10 BLE module with arduino according the schmatics and we will control the on board pin 13 led with the Android app but you can attach a LED to pin 13 as well. Well i'll attach a LED to pin 13.

Step 3: Code

Please copy the following code and upload it to the arduino Board :

#include "SoftwareSerial.h"
SoftwareSerial HM10(2, 3); // RX = 2, TX = 3
char appData;
String inData = "";
void setup()
{
Serial.begin(9600);
Serial.println("HM10 serial started at 9600");
HM10.begin(9600); // set HM10 serial at 9600 baud rate
pinMode(13, OUTPUT); // onboard LED
digitalWrite(13, LOW); // switch OFF LED
}
void loop()
{
HM10.listen(); // listen the HM10 port
while (HM10.available() > 0) { // if HM10 sends something then read
appData = HM10.read();
inData = String(appData); // save the data in string format
Serial.write(appData);
}

if (Serial.available()) { // Read user input if available.
delay(10);
HM10.write(Serial.read());
}
if ( inData == "F") {
Serial.println("LED OFF");
digitalWrite(13, LOW); // switch OFF LED

}
if ( inData == "N") {
Serial.println("LED ON");
digitalWrite(13, HIGH); // switch ON LED

}
}

Step 4: App Setup

The Arduino Bluetooth Controller (HM-10 Module) is an android application which is available free on Google Play Store. This app is having easy and simple interface for HM-10 BLE Module. While testing, it was able to find HM-10 quickly and it connected instantly with HM-10. The app has some cool feature like you can create a button and customize it with custom name and functions.


Download the app from Google Play Store. :
App name : Arduino Bluetooth Controller (HM-10 Module)

The Home page of the app will look like below where you can find features like, connect Device, Search Icon, Delete Icon, Device Status, Send Text, Add Template etc. Start with searching the Device either by clicking on Search Icon or by clicking to three dots on the upper right corner and choose connect Device.


All available devices will be shown in the screen. Choose the correct HM-10 Module.

Now the HM-10 will be successfully connected and you will be able to see the status of HM-10 in the Top of Screen.

Now either you can directly send a text or String by writing on the text section and hit arrow to send or you can create a custom template.

To create a custom template to save time. Click on the “+” icon on upper right corner and fill the details. The “Name” is button name, the “Text” field is for texts or string which will be sent to HM-10 and “Description” is just the button description that how the button will function.

Firstly, create a button for turn LED ON and give it a Green Color. The Button will send “N” letter to HM-10 which will turn on the LED connected to Arduino. Similarly create a button for LED OFF and give it a Red Color. . The Button will send “F” letter to HM-10 which will turn off the LED connected to Arduino.

Now you can see the two buttons created just below the Text Field. Now if you want to control LED then just click on the Buttons.


This finishes the setting up android app to control the HM-10 module. Now we will start with the programming Arduino Uno to get the characters from Android App.

Step 5: Testing the BLE Module

After setting the Android app and Uploading the code to arduino, we are ready to test the BLE module, so go to Android app and when you click on LED ON then LED will turn and when you click on LED OFF then LED will turn off, so have fun interfacing HM-10 BLE module in your arduino Projects.

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions