This is a shortened version of the getting started guide intended for experienced software developers.

Description

Open Energy Playground is (among other things) a collection of docker images and tutorials/reference projects on how to use these images to create Internet of Things prototypes.

It is a description of best practices and guidelines established at the Interactive Institute Swedish ICT, after years of experience.

Installation

git clone https://github.com/op-en/playground.git  
cd playground  
docker-compose up -d  

This will give you the base line of tools that are used in most projects.

Prototype Architecture

The basic procedure for many projects is actually the same:

  1. Get the data that you want to measure into MQTT.
  2. Use the graphical programming environment node-RED to wire up a small program that listens to the MQTT topics where data is coming in, connect it to a small function to process the data, and send it off somewhere else/do something with the information. This could be to trigger an alert, save the sensor data in a database. Or most of the time, publish another MQTT message on a different topic indicating a state change.
  3. Have a front-end/visualization that listens to the state topic via MQTT, and updates when it gets a message.

This architecture is fault tolerant and highly customizable, because all parts of the system are isolated from each other. The sensors don't have to care about what to do with their data, they just send it off. And the visualization/front-end doesn't have to care about how the new state was generated, just how to display it.

And in the middle of this sits node-RED, supercharged with Node.js powers to make it performant, yet lightweight. Beautiful!

A common additional step is to have a small script in node-RED that saves the relevant data in a time-series database (like InfluxDB). Then we use a graphing tool (like Grafana), to view the historical sensor data.

The Tools

MQTT - mosquitto

MQTT is a message protocol that has been around for a long time. It is:

  • Stable enough to be run in almost any environment.
  • Lightweight enough to be run in low power

This makes MQTT a good choice for a center point when building IoT prototypes.

Other message protocols are:

  • AMQP, too advanced in many IoT contexts. (But great for server side)
  • STOMP, not as widespread as MQTT.
  • XMPP, might be an alternative in some scenarios.

Mosquitto is an open source MQTT broker. It is actively maintained and supports websockets. Alternatives include RabbitMQ and HiveMQ.

InfluxDB

InfluxDB is a time-series database, a sort of no-sql document database optimized to handle high write and query loads. Perfect for sensor data!

It is a quite new database, so it is still a bit rough around the edges. But the 1.0 release is just coming up, with promised stability improvements (June 2016).

It can be a bit tricky to get started with, see our database tutorial.

Grafana

Grafana is a graph tool that goes great together with InfluxDB.

It can, just like InfluxDB, be a bit tricky to get started with, see our graph guide.

node-RED

Node-RED is a graphical programming environment where the things that you almost always have to do are available as configurable building blocks that you can connect together. Like HTTP requests, MQTT commands etc.

That way you can focus on what is important in your prototype: the application code.

With a big community, there is almost always a node available that does what you want. And if not, it is easy to take an existing npm package and add some graphical goodies above it.