This feature has been added to the robot AWBB v2.0
Why using Bluetooth LE?To export data from the robot to the internet we have chosen to link it to a mobile device using this new kind of connection: the Bluetooth LE (Low Energy). It's made for connected object (Internet of things for example) and it has the particularity to consume a few quantity of energy.
We have chosen the BLE-LINK v1.0 from DFRobot as it's easy to configure, it use a serial connection and allows 5V on RX pin.
To learn more on Bluetooth LE, go on Wikipedia
Due to lack of available pins, we decide to connect the BLE-Link as follow:
- TX pin of the BLE-Link to the SPI/ICSP connector on SCK
- RX pin of the BLE-Link to the SPI/ICSP connector on MISO.
Powering the BLE-LinkRegarding BLE-Link power, we encountered a small problem, as it based on xBee board powered with 3.3V and having only 5V on the Robot, we decided to solder a USB female plug on the Robot to have 5V and connect it to USB port of the BLE-Link using a standard USB cable.
Initialize and configure the BLE-Link
You will find all these information on the DFRobot Wiki page of the BLE-Link
You have to include the SoftwareSerial library to your project but with Arduino IDE 1.5.4 some core arduino header files must be patched to be able to compile.
You have to add these 4 definition (digitalPinToPCICR, digitalPinToPCICRbit, digitalPinToPCMSK, digitalPinToPCMSKbit(p) ) into the pin_arduino.h file in these following directories:
How to use 2 devices using SoftwareSerial library?When you have 2 devices using SoftwareSerial library it's important to choose which one of the devices will be the main one, the one who will listening the RX pin. Once this device has received something and realized its treatment, the second one can realize a request or get its data from its RX pin.
In our case on motor board, on beginGPS() we start the serial connection to te GPS and close it:And each time the GPS needs to be processed the processGPS is called:
The rest of the time can be used to listen the RX port for the Bluetooth device: