I wanted to control an Arduino UNO board using my android phones Bluetooth. The UNO board doesn’t have Bluetooth and so requires an external Bluetooth module. I found a small Bluetooth module (BOLUTEK BLK-MD-BC04-B) at digibay.in and purchased it for experimenting.
The BC04 module can be interfaced to your designs using UART. Before pairing with a device, the module enters into a command mode and can be configured using AT commands. Upon pairing with a device the module enters into a communication mode.
Documentation of the module:
BLK-MD-BC04-B Bluetooth Module Specification
BOLUTEK BLK-MD-BC04-B Bluetooth Module AT Commands
Testing the BC04 Bluetooth module:
Since I bought only one module I wanted to be extra careful, and so built a PCB for the module. The design is just an extension of the Application Circuit Diagram from the module specification file.
JP1 and JP2 bring out the extra functionality pins of the module. I left them unused on my PCB. To get started, first I configured my board to use a hardware selectable master/slave mode by placing a jumper between PIO(4) and GND at JP6. Then I set the board into slave mode by placing a jumper between PIO(5) and GND.
To test communications with the board, I connected a USB to TTL serial cable to JP4 and opened up a serial terminal on my laptop. The modules default baud rate is 9600 (Data bits: 8, Parity: None, Stop bits: 1, Handshaking: None) and the commands sent should be terminated with CR and NL characters.
I crossed my fingers and sent the “AT” command and got a reply “OK” from the module. Ah! I felt relieved that my module and PCB worked. I then played around with a few more AT commands to check the defaults of the module.
Connecting to the module using Android:
I wrote a small android app that allows me to chat with the Bluetooth module. The app acts as a Bluetooth Client that connects to the module and shows the communications as a chat list.
To connect to the module, the user has to click on Connect to Remote Device and pick the module from the list (generated using paired devices/Bluetooth discovery). Once the module is picked, the app tries to connect to it using the obtained module address and a common UUID for SPP “00001101-0000-1000-8000-00805F9B34FB”
Once connected, the module sends the following to the UART pins:
Where punkisnail is my phones Bluetooth name and d1:54:61:41:25:fb is its address.
After the connection is established the module and android device can communicate with each other and the messages are shown as a chat list in the app. Here, I sent a message hello from the terminal and received it in the app. I then sent a message “hi” from the app and received it in the terminal (via the Bluetooth module).
When the connection terminates the module returns to the pairable mode and shows the following in the terminal:
Now I’m ready to connect the Bluetooth module to my Arduino Uno and build a bluetooth controlled mobile robot. See ya in my next blog post 🙂