Search

Control Your Arduino Ble Device Using Smartphone

About the project

This explains how to control devices using BLE and smartphones.

Project info

Difficulty: Moderate

Platforms: AdafruitArduinoSparkFun

Estimated time: 4 hours

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Breadboard (generic) Breadboard (generic) x 1
Resistor 1k ohm Resistor 1k ohm x 1
LED (generic) LED (generic) x 1
Buzzer Buzzer x 1
adafruit ble uart friend adafruit ble uart friend x 1
SparkFun Arduino Pro Mini 328 - 5V/16MHz SparkFun Arduino Pro Mini 328 - 5V/16MHz x 1

Software apps and online services

Arduino Web Editor Arduino Web Editor
Adafruit blufruit LE android a Adafruit blufruit LE android a

Hand tools and fabrication machines

Soldering iron (generic) Soldering iron (generic) x 1

Story

Part 1

Bluetooth is one of the main connectivity technique used for short range connectivity in many devices. After the evolution of Bluetooth Low Energy it becomes more attractive to engineers and DIY hackers because of its low energy consumption. Many modules are available in the market which are easily interfaceable with  ‘Hackers toys’ like Arduino, Particle, Raspberry Pi, etc. Because of this high demand Arduino release their Arduino 101/Genuino 101 with inbuilt BLE module and Raspberry Pi3 has also got the inbuilt BLE.

This is the era of smartphones. People's daily life is highly depends on their smartphones. Almost all wearables are communicating with smartphones Via Bluetooth. There are many application of BLE in healthcare devices also which senses body sensor values like heartbeat and transmit into smartphones and then to cloud.

Part 2

I have worked on classic Bluetooth module HC05 as well as Adafruit Bluefruit  BLE module. Many BLE modules are available in the market. In my research most of these BLE modules are working in peripheral mode. In this mode modules only can advertise their payload. It can not scan any other BLE modules in range. For scanning you will have to use BLE modules which supports Central mode. Usually the BLE modules in laptops and  smartphones are coming with central mode. There are some DIY friendly central mode supported Bluetooth modules also available in the market. None of them are tested by me. HM10, BLE mini RedBear and BLE Nano RedBear are such modules which can be used in central mode.

Adafruit Bluefruit LE UART Friend is One of the coolest and easily interfaceable BLE modules available in the market. Since it is developed by Adafruit there are many documentation and tutorials are available in the internet. Adafruit also giving an Arduino support library.

The examples are  written to communicate with adafruits bluefruit LE app. There are codes available for BLE as beacons, uribeacons, eddystones, etc. Now I would like to explain how to modify this codes to our way. Ie how to control things using your smartphone and BLE.

Example for Arduino BLE to Android Communication

You can find the Fritzing file here.

List of components
  • Arduino Pro Mini
  • Buzzer
  • LED
  • Resistor 330 ohm

Connections
  • Arduino pin 9 ----Bluefruit RX
  • Arduino pin 10---Bluefruit TX 
  • Arduino pin 11---Bluefruit CTS
  • Arduino pin 12---Bluefruit Mode pin
  • Arduino GND---Bluefruit GND
  • Arduino Vcc---Bluefruit Vcc
  • Arduino pin 3---led
  • Arduino pin 6---Buzzer

This example demonstrates how a device can be controlled using your smartphone. Here I am controlling an LED and buzzer using an Android app. This device will read incoming data from any other BLE device (which is working in central mode) and do actions.

Incoming data                      Actions

  • character 1(ASCII49)  ----------  LED ON
  • character 2(ASCII50)  ---------- LED OFF
  • character 3(ASCII51)  ---------- will reply "Thank you for reading wiring it my way"
  • character 4(ASCII52)  ---------- BUZZER ON
  • character 5(ASCII53)  ---------- BUZZER OFF

You can use your own BLE app. Here I am using Bluefruit LE app from Adafruit. In that after pairing your device to your phone open UART mode in your app and send different characters like 1, 2, 3, 4, 5 and test your BLE. As you know this is only the basic intro off BLE. Now try your own devices like BLE controlled toys, sensor data apps etc. Please commend your BLE experiences.

Schematics and circuit diagrams

Fritzing

http://fritzing.org/projects/control-your-arduino-ble-device-using-smartphone

Code

Github

https://github.com/dalintakam/Adafruit_BluefruitLE_nRF51

Arduino

https://create.arduino.cc/editor/dalintakam/b4895a90-2387-4b3a-9ffa-89be62347b2b/preview?embed

Download

Credits

Photo of anas

anas

Electronics and communication engineer || DIY hobbyist || IoT enthusiast || Blogger||Startup||Medtech

   

Leave your feedback...