The post is all about the detailed tutorial on Bluetooth Low Energy (BLE) with HM-10 BLE 4.0 with Arduino.
Overview
Bluetooth, a simple wireless communication module most popular since the last few decades and easy to use are being used in most of the battery-powered devices. Over the years, there have been many upgrades of Bluetooth standard to keep fulfil the demand of customers and technology according to the need of time and situation. It all started from Bluetooth version 1.0 and currently, Bluetooth version 5.0 is available in the market. Over the few years, there are many things changed including data transmission rate, power consumption with wearable and IoT Devices and Security System.
To learn about the Bluetooth working, HC-05 & HC-06 is widely available in the market. But here we are going to learn about HM-10 BLE 4.0 with Arduino Board. The HM-10 is a readily available Bluetooth 4.0 module. This module is used for establishing wireless data communication. The module is designed by using the Texas Instruments CC2540 or CC2541 Bluetooth low energy (BLE) System on Chip (SoC). The module design and firmware originated from the Jinan Huamao Technology Company.
You can check this project based on Classic Bluetooth: Wireless Caller ID Display for Bikers using Bluetooth & Arduino and also learn about the differences between Classic Bluetooth Vs. Bluetooth Low Energy.
Components Required
The following are the components required for BLE 4.0 Tutorial. All these components can be purchased from Amazon. The purchased link is also given.
S.N. | Components | Quantity | Purchase Links |
---|---|---|---|
1 | Arduino UNO Board | 1 | Amazon | AliExpress |
2 | BLE 4.0 HM-10 | 1 | Amazon | AliExpress |
3 | Connecting Wires | 10 | Amazon | AliExpress |
4 | Breadboard | 1 | Amazon | AliExpress |
Bluetooth Low Energy (BLE)
Bluetooth Low Energy (formerly marketed as Bluetooth Smart) is a wireless personal area network technology designed and marketed by the Bluetooth Special Interest Group (Bluetooth SIG) aimed at novel applications in the healthcare, fitness, beacons, security, and home entertainment industries. Compared to Classic Bluetooth, Bluetooth Low Energy is intended to provide considerably reduced power consumption and cost while maintaining a similar communication range. Mobile operating systems including iOS, Android, Windows Phone and BlackBerry, as well as macOS, Linux, Windows, natively support Bluetooth Low Energy.
Applications of Bluetooth Low Energy (BLE)
As the name suggests, BLE focuses on low energy consumption. Low energy focus comes with some sacrifices particularly around data transfer rates and the range of operation. With all the hype around IoT (Internet of Things) and the slew of technologies and devices out in the market, BLE is attempting to position itself as a leader for the future of IoT. Some of the many suitable applications for BLE are:
1. Fitness trackers (such as Fitbit, Misfit)
2. Smartwatches (such as the Apple Watch, Moto 360, and Pebble)
3. Beacons (Apple iBeacon, Google Eddystone)
4. Medical devices such as glucose meters, insulin pumps
5. Home automation devices such as door locks, light bulbs, sensors, and others
Learn about BluetoothLow Energy 5.0 Here: BLE 5.0 Chip nRF52840
Advantages
1. Low power consumption
2. Low bandwidth – perfect for collecting data from sensor devices
3. Proliferation in smartphones
4. Relatively simple development process
5. No fees to access the core spec
6. Low development and module costs
7. No outrageous licensing costs compared to other low power wireless technologies
Disadvantages
1. Low bandwidth – not suitable for large data transfer applications
2. Limited range (typically 30 -100 m, but steadily increasing with each iteration of the spec)
3. Requires a gateway device to connect the end devices to the Internet (smartphones, dedicated gateway devices)
4. Interference and noise from other protocols in the 2.4 GHz spectrum (WiFi, Bluetooth classic, ZigBee etc)
5. Can be difficult to debug issues with communications especially relating to longer ranges and interference
HM-10 BLE 4.0
The HM-10 is a small 3.3v SMD Bluetooth 4.0 BLE module based on the TI CC2540 or CC2541 Bluetooth SOC (System On Chip). There are 2 versions of the HM-10; the HM-10C and the HM-10S.
The HM-10 is has become a very popular Bluetooth 4.0 BLE module for use with the Arduino. In part due to the standard UART serial connection that makes it fairly straight forward to connect to an Arduino. The UART layer is a good thing and a bad thing, it allows ease of use but it hides the BLE layer so you have no control over the actual BLE side of things. The HM-10 is Bluetooth version 4.0 only. This means it cannot connect to Bluetooth 2/2.1 modules such as the HC-06 and HC-05. The HM-10 is controlled via AT commands which are sent over the serial UART connection.
HM-10 Breakout Board
The HM-10 is also available mounted to a breakout board that exposes the power and UART connections to breadboard-friendly male pins. The breakout board includes a 3.3v power regulator that makes them 5V compatible. You should note that the RX pin is still 3.3v and when using a 5v Arduino you should covert the Arduino’s 5v TX to 3.3v for the HM-10 RX.
1. STATE: state test pins, connected to internal LED, generally keep it unconnected.
2. RXD: serial interface, receiving terminal.
3. TXD: serial interface, transmitting terminal.
4. GND: Ground.
5. VCC: positive pole of the power source.
6. EN/BRK: break connect, it means breaking the Bluetooth connection, generally, keep it unconnected.
Interfacing HM-10 BLE 4.0 with Arduino
The below circuit diagram gives a basic idea how a HM-10 can be interfaced with Arduino UNO.
The VCC is connected to 5V pins of Arduino and GND to GND. Using the software Serial function the TXD Pin of HM-10 is connected to D2 of Arduino and RXD Pin to D3.
Source Code Program for HM-10 Arduino ED blinking
The simple program here explains how you can Turn ON and Turn OFF the built-in LED at digital Pin 13 of the Arduino. Copy this code and upload it to the Arduino Board.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <SoftwareSerial.h> SoftwareSerial mySerial(2,3); int ledpin=13; void setup() { mySerial.begin(9600); Serial.begin(9600); pinMode(ledpin,OUTPUT); } void loop() { int i; if (mySerial.available()) { i=mySerial.read(); Serial.println("DATA RECEIVED:"); if(i=='1') { digitalWrite(ledpin,1); Serial.println("led on"); } if(i=='0') { digitalWrite(ledpin,0); Serial.println("led off"); } } } |
BLE Scanner Android App
- Download an App called BLE Scanner from the playstore.
Download Link: BLE Scanner
- Once the installation is completed, open the App and enable Location and Bluetooth permission.
- Scan for the bluetooth devices. The name of HM-10 BLE 4.0 is MLT-BT05. The default pairing code for MLT-BT05 is 123456789. So once connected, you are ready to go now.
- Now once the connection with MLT-BT05 is done, click on it and you will get many options like Device Information, Generic Access, Generic Attribute, Custom Service. Out of all these options click on Custom Services.
-
Once Custom Service is selected there will be blue colored circular option written as R, W, N which means read, write and notify.
-
Click on W and send 1 or 0 to control the inbuilt LED of Arduino Board.When you send ‘1’ the LED wil turn ON and when you send ‘0’, the LED will turn OFF.
2 Comments
How did you hook wire it up without a voltage divider circuit for the 3.3v rx pin?
Agreed, this wiring could fry the HM-10 chip without the voltage divider on the Rx pin. A quick google image search of “HM-10 voltage divider” will show how to properly place the resistors to get 3.3 V. You will need a 1k ohm and a 2k ohm resistor (or two 1K ohm resistors in series).