Intro: IoT Your Arduino Using Bluetooth and Andriod Smart Phone (MQTT Tethering)
I want to try IoT using the MQTT protocol (http://mqtt.org/), in order to do this most of Arduino recipe uses Ethernet or WIFI, but I have only bluetooth HC-06, so I utilize my smartphone as hub to access internet through it
attached video contains what I achieved before in other project using this recipe, I will cover here only the connectivity and libraries used.
Step 1: Install Arduino Required Libraries
Two libraries used in this project json library and custom made library to tether mqtt protocol for the Android smart phone, over software Serial.
you can download both libraries from here
Hint : as per the attached image you can directly download the library from github using Download Zip button and extract it to Arduino Library folder at the Arduino IDE installation path
Step 2: Hardware Steup , Connect Arduino to HC-06
In this project I use HC-06 similar to what happen in a previous instructable you can find in the below address
but instead connect the RX,TX with 10, 11 digital output pins because our sample code uses Software Serial.
Step 3: Setup You Andriod Application
This android application needs some improvements to detect MAC address, you need to insert the MAC address manually, for simplicity I hard-coded the first 4 bytes they should be the same for all HC-06 from same supplier.
you can find the Android application source code using Android Studio here, and tweak it to fit your module
Hint: Please insure your phone paired with the HC-06 and your bluetooth turned on before press connect
Step 4: Testing Your Application
This is just a sample to test your connectivity setup, we are going to use IBM provided quickstart service you can use it to it chart your sensor readings, just provide the HC-06 module MAC address and wait for the reading.
Upload attached test.ino to your Arduino, insure updating line 7 with your module info
for example if your mac address is (00:14:03:18:XX:XX), your constructor should be as follow
MqttSerial mqttSerial ("d:quickstart:instructable:00140318XXXX",bluetoothSerial);
the attached code read A0 Analog input pin and publish the data over quick start Mqtt protocol and the data get charted by this magical IBM web page
Step 5: What Is Going to Happen
Finally, it works the result is from my experiment, this is not an actual sensor data but it is the noise on A0 pin however it gives a very interesting chart too :) :)