14th Apr 2015
IoT Experiments – geo-data to cloud (MQTT)
In continuing with my experiments with IoT,
I was googling for ways to send mobile phone data (battery level, GPS location) to a centralized server using MQTT. The nice thing about a MQTT broker is that it is light weight (compared to other message bus and is well tuned for sensor data; further, it also has some QOS as part of the protocol).
Step 1:
I setup a Mosquitto based MQTT broker (on an Ubuntu 12.04 laptop)
http://mqtt.org/
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
su /etc/init.d/mosquitto start
su /etc/init.d/mosquitto stop
Testing:
to subscribe – mosquitto_sub -d -t hello/world
to publish – mosquitto_pub -d -t hello/world -m “hello”
Step 2:
I looked for a mobile app – fortunately OwnTracks (http://owntracks.org/ and https://github.com/owntracks/ios seem to be the best choice). It is a small app (also available for Android) that sends geo-location to a MQTT server (set up above – all this would be inside a private network).
I downloaded the owntracks app from Apple store and configured it to send data to the server above.
Note:
The MQTT server does not store any information.
On the laptop – mosquitto_sub d -t owntracks/chandra/iphone
On the iphone owntracks app – choose Host ip address (laptop address), default port (1883) and Topic owntracks/chandra/iphone
A quick way to test is to press the square blue button on top (Location Monitoring Mode) and click on ‘Public Now’ button – this will send out a MQTT packet to the MQTT broker (you will see it on the laptop window that is running mosquitto_sub program)
Leave a Reply