Important: Zoetrope Labs has decided to close down after 5 great years of business. The team are moving on to new adventures. This site is left up for reference only.

Really simple MQTT IoT logging with Keen IO

We’ve blogged about Keen IO before, and love using MQTT in our IoT projects. So we decided to combine the two!

Announcing KeenMQTT.

MQTT is perfect for distributing and acting on near realtime data, but there isn’t much in the way of historical data access. That’s where KeenIO comes in.

We’ve recently created and open sourced a library/CLI app which we’re calling KeenMQTT


Imagine you have a bunch of temperature sensors that are used in an existing system to control your home heating. A good approach to networking those sensors would be MQTT. Each sensor posts to a particular topic and the boiler controller subscribes to those topics.

Now, you’d probably want a dashboard, and it’s easy enough to get the current temperature data via MQTT: just subscribe to the temperature topics using your client library of choice. But what about historical temperatures? For that we need some kind of data storage. KeenIO is a nice choice with easy data analysis APIs and fancy looking graphs.

So the overall system would look something like this:

Keen MQTT System

To hook up the MQTT server, the KeenMQTT adapter needs to subscribe to some relevant topics and map those onto a KeenIO collection. You can do this through the config.yaml file e.g.

collection_mappings:    ‘temperature/+’ : temperature

Live Example

To give you an idea of how this works in practice we’ve hooked up a temperature sensor to our MQTT broker.

Here is a graph of temperature over the last 24 hours. This is pulled directly from KeenIO, using their visualisations library to display it as a line graph

client.draw(temp, document.getElementById("bristol-temp-24"), {
  chartType: "linechart",
  title: "Bristol Temperature (24 Hours)"

And here’s the computed average temperature in Bristol from our data points:

Using the adapter

The adapter is extremely extensible and customisable. The code is well documented on Read The Docs and there is a pypi module available. Payloads can be customised very easily and the package can be run standalone from the command line or through python.


KeenMQTT should be useful for anyone who wants to get up and running with an IoT application using MQTT. Often you don’t want or need the complexity of a full fledged IoT platform, and this can help bridge that gap.

We hope you find it useful, and we’d love to hear about it if you find an interesting application for it.

At Zoetrope we use MQTT a lot in our internet of things development, do get in touch to find out more about our consulting services.