Blog

NodeMCU, MQTT, IoT & Other Letters I Find Exciting

If youā€™ve been keeping up with my #SmartHomeĀ series (and if you havenā€™t, why not?) youā€™ll already know that I have plans to make more of my home ā€œsmartā€ using Home
Assistant
as the software that ties everything together, and some DIY NodeMCU-based hardware that Iā€™m going to build myself as a learning opportunity.

Another important piece of the puzzle, but one that I havenā€™t previously mentioned, is MQTT.

MQTT is ā€œa publish-subscribe-based lightweight messaging protocol for use on top of the TCP/IP protocol,ā€ at least according the slightly suspect grammar of the person that wrote the Wikipedia article about it.

image

I learned about MQTT at the same time I learned about Home Assistant, although I didnā€™t initially appreciate its power. Iā€™ve been using it from the start to enable Home Assistant to know where we are: our phones run an app called OwnTracks which publishes
location data to an MQTT ā€œbrokerā€ (server). Home Assistant subscribes to these updates, which means it immediately knows about it when our location changes.

I love this whole solution, not least because itā€™s very easy to run my own MQTT broker (Iā€™m running MosquittoĀ in a Docker container on my home server) and Iā€™m therefore entirely in control of our location data ā€“ itā€™s not being shared with the developer of some app or service I have no insight into.

This publish/subscribe model and the lightweight nature of MQTT makes it perfect for ā€œInternet of Thingsā€ (IoT) devices to communicate with each other, and when you add Home Assistant into the mix it gives me all the tools I need for any sensors I build
to feed their data into my smart home ecosystem, and for my smart home controller to feed commands to any devices.

Indeed, Iā€™ve already built my first little NodeMCU app that leverages the technology.

Iā€™ve ordered almost all the components I need for my upcoming hardware projects from China, and theyā€™re only just starting to arrive. Happily the NodeMCUs themselves were amongst the first shipments to land on my doorstep, so even though the only thing I can really do with them right now is programmatically turn their internal LED on and off, I have still been able to use this to start learning: Iā€™ve made it an internet controlled
LED.

[youtube https://www.youtube.com/watch?v=JLETpLMicYs?feature=oembed&enablejsapi=1&origin=https://safe.txmblr.com&wmode=opaque&w=540&h=304]

As promised, Iā€™m going to be sharing both the hardware and the software as I take this DIY Smart Home journey. There is no DIY hardware here, just the NodeMCU itself, but Iā€™ve published both the Arduino sketch and Home Assistant configuration Iā€™ve used for the video.

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *