Some of my friends have been using Google's Latitude on their children's phones (with the child's consent), and they were a bit miffed when I told them the program was being retired. How would they keep track of where their children are in future?

It occurred to me that it would probably be pretty easy (for somebody in the know) to build something which is capable of recording a device's position and reporting that position via MQTT. In addition, this would enable people to quite easily set up their own infrastructure for recording this data, and keep that data private.

Somebody suggested using HTTP with, say, Android's Tasker app, which could periodically determine GPS coordinates and POST them to an HTTP endpoint, but apart from requiring that special app (which is non-trivial to configure), there are numbers that indicate HTTP may consume more power than MQTT. Be that as it may, I feel MQTT is the best solution to the problem, and others are also using it on a large scale.

I talked with Alexander Rust (one of the authors of homA). Alexander has experience with Android programming, and he was willing to give it a try. He quickly produced a prototype app for Android as well as a back-end for mapping location. The program, OwnTracks is a work in progress, but let me show you what the app is already capable of.

I borrowed a small Android phone, loaded the app onto it, and configured it to connect to an MQTT broker and periodically publish the phone's location to that broker, on a particular topic.


The app's preferences allow setting all important switches: broker address/port, topic name, optional credentials and TLS. (I've asked Alexander to add a retain flag.)

mqttitude prefs

The app then connects to the broker, determines the device's position and publishes that to the MQTT topic I configure.

mqttitude status

The MQTT payload the broker receives is a set of latitude/longitude coordinates separated by a colon. (The payload will later include an epoch time stamp.)


I can subscribe to the broker and store these coordinates in simple files, a database, etc. Using OpenStreetMap I can rather easily put a pin on a map. I could also do this with Google Maps of course (until that too is retired? ;-)

leaflet map

Using, say, Nominatim, I can reverse geo-code the location and determine a printable location:

    "address": {
        "city": "Pfungstadt", 
        "country": "Deutschland", 
        "country_code": "de", 
        "county": "Darmstadt-Dieburg", 
        "postcode": "64319", 
        "road": "Rastst\u00e4tte Pfungstadt Ost", 
        "state": "Hessen", 
        "state_district": "Regierungsbezirk Darmstadt", 
        "suburb": "Eich", 
        "telephone": "615700919865"
    "display_name": "615700919865, Rastst\u00e4tte Pfungstadt Ost, Eich, Pfungstadt, Darmstadt-Dieburg, Regierungsbezirk Darmstadt, Hessen, 64319, Deutschland", 
    "lat": "49.81158139", 
    "licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0.", 
    "lon": "8.57908623", 
    "osm_id": "710808530", 
    "osm_type": "node", 
    "place_id": "6890865"

Alexander is working on a back-end to do the plotting on a map, and the bits and pieces are in the mqttitude repository, but I haven't yet had the chance to experiment with them.

Is this useful for a larger number of people? I think so. If somebody wants the location information that Google's Latitude used to provide, they can easily install Mosquitto onto, say, a Raspberry Pi (the card-sized computer is more than capable enough of running Mosquitto) and start collecting location data. One very important fact is that the data I collect is mine; I can keep it secret!

Is any of my readers willing to crank up Xcode, load libmqtt for iOS and create an iOS app which mimics the Android app? That would be great!

Flattr this
MQTT, latitude, and GPS :: 14 Aug 2013 :: e-mail


blog comments powered by Disqus