PlatformIO, Homie-ESP8266 nodes & MQTT fun

Alright, so this is a quick primer on PlatformIO, Homie-ESP8266 and MQTT.

So first, what is MQTT?

MQTT (or Message Queue Telemetry Transport) is a protocol designed for sending information in as simple a manner as possible. It follows a simple transactional approach where you can PUBLISH or SUBSCRIBE.

Let's assume we're running an MQTT server (or in MQTT-speak, an MQTT Broker):

The MQTT BROKER (server) supports a number of TOPICS which can be written to by authorized and authenticated clients. In our case, the clients are wireless esp8266 microcontroller devices with temperature, humidity and light sensors.

An authenticated MQTT CLIENT can either PUBLISH a message, text or number value to something called a TOPIC. The TOPIC is how we'll access that data in the next example below.

Another MQTT CLIENT can also SUBSCRIBE to that TOPIC in order to retrieve that message, text or number value by requesting that TOPIC.

Sounds pretty straight forward. It's practically a messaging application without any frills of any kind, no UI, no nothing.

Moving on, what is PlatformIO?

I mentioned PlatformIO in my last post. PlatformIO is a development framework for Internet of Things devices. Basically, it'll abstract your code from having to only be capable of working with a single piece of hardware to potentially working with any other piece of hardware that may support it.

It does this by wrapping itself around a bunch of software development libraries. I'm not nearly nerdy enough to start talking about software toolchains and the amount of work that went into this, but suffice it to say: It's really cool.

Okay, fine but what does that mean practically and in plain english?

It means, if I write code. Someone else can take that code and make it work with any other supported microcontroller or device that is supported by the PlatformIO framework. Basically, since I have two different microcontroller's (the Adafruit Huzzah) and the Wemos D1 Mini of which both are based on the esp8266 chipset; I can develop for both at the same time with very little changes that need to be made to my code. In theory anyway.

So, it makes writing software for multiple IoT devices easier.