Saturday, September 10, 2016

Control Your Arduino BLE Device Using Smartphone

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.
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 scaning 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 samrtphone and BLE.

 Example for  arduino BLE to android communication





You can find the fritzing file here
You can find the hackster project here
  List of components
  1. Arduino Pro Mini
  2. Adafruit Bluefruit LE UART Friend 
  3. Buzzer
  4. LED
  5. Resistor 330 ohm
  6.  bluefruit LE app or any other custom designed android app
Connection
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 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.

 




No comments:

Post a Comment