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

by Utsource in Circuits > Arduino

763 Views, 0 Favorites, 0 Comments

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

Circuit-Hardware-for-HM-10-BLE-Module-with-Arduino-to-Control-an-LED-using-Android-App.jpg
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.

Things You Need

HM10 BLE-4-Module.jpg
Km5Zu-2RIncAUweU7uG7IhyWPySZ0SqIgAI0-vk9w7767_IkthCPCcsirj2GGmXF4IdQDg8UVpHVLVM6CXnzFsG1hnAdSkK7BIhIOtEldXoZiDsvzsPo-6o0rD6Mda7UyOE=w456-h323-nc.png
electronics-kit-resistor-led-button-breadboard-wire-1697-1024x1024.jpg

For this instructables we will need following things :

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

Schmatics

Circuit-Diagram-for-HM-10-BLE-Module-with-Arduino-to-Control-an-LED-using-Android-App_0.png
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.

Code

images(101).jpg

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

}
}

App Setup

Arduino-Bluetooth-Controller-HM-10-Module- Android-App.png
Arduino-Bluetooth-Controller-HM-10-Module- Android-App-Homepage.png
Connecting-HM10-to-Mobile-Phone.png
Connected-HM10-to-Mobile-Phone.png
Sending-Data-from-Mobile-Phone-to-HM10.png
Adding-Template-to-Bluetooth-Andriod-app.png
Adding-Button-to-Bluetooth-Andriod-app.png
Turning-ON-and-OFF-LED-using-HM10-Bluetooth-Module.png
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.

Testing the BLE Module

Screenshot_20191114-101819__01.jpg
Screenshot_20191114-101825__01.jpg
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.