Advertisement

Getting Started with BLE and Arduino

The MLT-BT05 is a readily available, inexpensive Bluetooth 4.0 module based on the Texas Instruments CC2541 Bluetooth Low Energy (BLE) system-on-chip (SoC), sold by various Chinese suppliers and several U.S. and European distributors. Although the fairly small module resembles the famous HM-10 BLE Bluetooth 4.0 modules from Jinan Huamao Technology Company (JNHuaMao), it’s actually a cheap clone of another BLE Bluetooth 4.0 module, the CC-41A. In this post, I’ll show you how to play with the cheap and cheerful BLE Bluetooth 4.0 module MLT-BT05.

 

Hardware Setup: First Run

Just follow the tried-and-tested hardware setup shown below to start playing with the BLE module. Note that most MLT-BT05 breakout boards do not have built-in logic level translators; thus, the UART remains in 3.3-V level and makes them unsuited for interfacing with the UART of Arduino Uno microcontrollers that run on 5 V. That’s why a 2/3 potential divider (see the 1K and 2K resistors) is deliberately added here in the RX path of the BLE.

 

Hardware wiring schematic for initial run and testing

 

Arduino Sketch: First Run 

/*

BLE Module– First Run

Hardware 1: MLT-BT05 BLE Bluetooth v4.0

Hardware 2: Arduino Uno R3

Experimental Sketch: By T.K.Hareendran

*/



#include <SoftwareSerial.h>

int bluetoothTx = 2; // D2 to TXD

int bluetoothRx = 3; // D3 to RXD  (Warning! See Text)

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()

{

Serial.begin(9600);

bluetooth.begin(115200);

delay(100);

bluetooth.println(“U,9600,N”);

bluetooth.begin(9600);

}

void loop()

{

if (bluetooth.available())

{

Serial.print((char)bluetooth.read());

}

if (Serial.available())

{

bluetooth.print((char)Serial.read());

}



}

 

To test this sketch, just open the serial monitor of the Arduino IDE, type “AT” into the text box, and press the “Send” button. Remember to select both NL and CR in the serial monitor (Baud Rate = 9600). If the hardware setup is okay, it will return with “OK.” All other “MLT-BT05 AT Commands” can be easily found on the internet. A noteworthy fact is that you can try compact versions of Arduino like the Nano v3(16 MHz @ 5 V) or Pro Mini (8 MHz @ 3.3 V) in lieu of the UNO used here. The 3.3-V version of the Pro Mini is more suitable here because you can drive it from a standard 3.7-V Li-ion battery and without any logic level shifter add-ons.

 

Hardware Setup: LED Test

Now is the time to control the onboard LED (D13) of Arduino through its serial monitor and, thereafter, through the Android app “Serial Bluetooth Terminal (1.9).” See the next Arduino hardware setup and accompanying sketch for the experiment. To test the sketch, just open the serial monitor of the Arduino IDE, type “1” into the text box, and press the “Send” button. If everything is okay, it will light up the LED connected with D13 of the Arduino. To turn off the LED, use “0” instead of “1.” That’s it!

 

Hardware wiring schematic for testing LED

 

Arduino Sketch: LED Test

/*

BLE Module– LED Test

Hardware 1: MLT-BT05 BLE Bluetooth v4.0

Hardware 2: Arduino Uno R3

Experimental Sketch: By T.K.Hareendran

*/


#define indPin 13

char data = 0;

void setup()

{

Serial.begin(9600);

pinMode(indPin, OUTPUT);

}

void loop()

{

if (Serial.available() > 0)

{

data = Serial.read();

Serial.print(“BLE LED TEST...”);

Serial.print(“\n”);

if (data == ‘1’)



digitalWrite(indPin, HIGH);



else if (data == ‘0’)



digitalWrite(indPin, LOW);

}

}

 

Hardware on the breadboard in my lab

 

Android LED Test

As noted above, an Android app is required to control the Arduino LED with your Android smartphone. Just download and install the “Serial Bluetooth Terminal (1.9)” app from the Google Play Store for sending commands 0 (LED OFF) and 1 (LED ON) to control the Arduino LED. You can also use the “Macro” feature of the app to make convenient shortcuts, too (see my screenshot).

 

Android serial terminal

 

Moving Forward With BLE Modules

To get a Bluetooth or other RF product on the market, there are various qualifications and approvals that you will need to meet to prove that the product meet wireless standards. Fortunately, a range of module suppliers offers qualified and pre-certified BLE modules suitable for wireless communication designs that have been optimized for low power consumption rather than maximum data transfer rates. The BLE may not be part of your open-protocol RF electronic designs just yet, but chances are that it will be soon. So get ready for an early start with BLE!

3 Comments

Join the conversation!

Error! Please fill all fields.
Looking for the latest from TI?