Microservices at home post

Lately I've been playing around with the ESP8266 chipset which is an IoT (Internet of Things) platform which couples digital IO pins with a WIFI connection (I will make another post about this, and link it later on).

ESP8266 ESP-12

ESP8266 ESP-12

What I like about IoT, is that everything is connected and reacting upon each-other. The thing I dislike though, is that the trend seems to be that every piece of hardware has a callback to the mothership (the company selling the equipment).

For example, I have a Philip Hue lighting system. The Hue-bridge device provides a REST-API so you can configure your lights just the way you want automatically. On the other hand, whenever you link it to the MeetHue system, it creates a callback to Philips so you can control your lights using the app, outside your WIFI network. The Nest thermostat does something similar.

Philips Hue Lighting system

Philips Hue Lighting system

When I first came in contact with the ESP8266, it was running the alternative firmware called NodeMCU. This firmware enables you to run Lua code on the chip with a few libraries at hand, including an MQTT client.

This was the first time i’d heard of MQTT, but after a quick google found out that this is ‘just a’ Message Queue like I know from RabbitMQ. The presence of this client library opened my eyes to lots of possibilities for IoT applications inside my home without the need of passing my home internet gateway.

A few examples that I’ve been playing around with

  • Controlling a WS2812B LED strip (driver included in NodeMCU :D)
  • Reading a temperature and humidity sensor from different places in my house
  • Reading out gas and electra readings from my Smart Meter using the P1-data port
  • Controlling the air circulation system inside my house (which runs on an NRF-remote)
  • Controlling 433Mhz equipment like power outlets (now controlled by a remote)

If I can use the MQTT protocol as a layer on top of all API’s and hardware, this would be kind of similar to how Microservices work.

MQTT Sequence Diagram

MQTT Sequence Diagram

After setting up an MQTT server (I use Mosquitto, since it supports the MQTT-3.1.1 protocol in the latest versions on my RaspberryPi2), I’ve build some small microservices to start playing with this concept:

I think i’m only at the start of everything that is possible, but i'll post updates on the expansion of my Microservice network at home.

Please let me know what you think, if you have any questions or feedback. I'm getting really excited about the subject!

Categories: Architecture, Microservices, NodeJS

Tags: ESP8266, Microservices, MQTT, NodeMCU, Philips Hue, WS2812B