I am sure everyone with an interest in technology has played with multiple hardware and software solutions over the years to build a patchwork quilt of hacked together home automation bits that don’t quite achieve the desired goal of home intelligence.
That’s not saying there are no elegant solutions out there that perform an admirable job, just not necessarily open, extensible, reliable, quick, cheap and easy that work across all platforms. Pure internet based systems also have issues. They can provide convenience, but they also encourage vendor lock-in, and create serious privacy and security challenges. Why should you expose your home systems to the internet if you only need to operate them within the home context? What if the internet is unavailable? What if the vendor database is hacked? You can always internet-enable a home-based system, but the reverse is not always possible.
Any solution should ideally be standards based and open source rather than yet another proprietary solution designed for lock-in. The very nature of the average home dictates that any solution must support a myriad of old and new devices from multiple manufacturers with very different purposes. Some just want to get their local weather sensor data, while others want to control serious devices in a fault tolerant manner.
The challenge is to find a way to unite and interact with these disparate sensing and control devices in a common language that is highly capable, yet simple to build and manage. Fortunately a combination of relatively new open source technologies have created the ‘Perfect Storm’ of capabilities to achieve this goal with relatively little effort. I have been lucky enough to have some good friends and a vibrant open source community that understand these technologies far better than I and have steered me in the right direction. Hopefully I can help steer others in the right direction, or at least save you a few hours of trial and error, by sharing my experiences.
The following are the key building blocks.
- Mosquitto – open source message broker implementing the MQTT protocol ref. http://mosquitto.org/. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model. In simple terms, it provides a way for devices to talk to each other eg. sense and control, simply and efficiently.
- Node-RED – Node-RED is an open source tool for wiring together hardware devices, APIs and online services in new and interesting ways. It runs on Node.js and provides a simple but powerful graphical programming interface to control the logic flows between devices ref. http://nodered.org/
- Arduino / ESP8266 etc. – Arduino is an open-source electronics platform based on easy-to-use hardware and software. If you need to build your own sense and control devices, there is no better way to start ref. https://www.arduino.cc/
- 3D Printing – 3D printing is revolutionising the DIY landscape. It is by no means essential, but if you have access to a 3D printer it opens amazing possibilities for creativity and augmentation.
This is a remarkably small list, but it is all that is needed to create a reliable low cost ecosystem that supports virtually all networkable devices and includes everything from device interfaces and full IP protocol support to comprehensive user interface and dashboard options that will run fine even on a smart phone.
Step by Step
An overview of the basic setup steps:
- Install Mosquitto on your desired network platform eg. a Raspberry Pi. This will be the messaging hub for your network.
- Install Node-RED on your desired network platform Note: The Raspberry Pi standard operating system ‘Raspbian Jessie’ has Node-RED preinstalled.
- If you are connecting an Arduino or ESP8266 device, add the relevant MQTT code to your sketch to publish and/or subscribe to the MQTT broker as required.
- Add the required flows to Node-RED to generate the required outcomes eg. take MQTT input, display on a dashboard, trigger an event etc.
- Finish off your devices with a nice 3D printed case or use 3D printed components to extend your devices into new areas.
As time permits, I will be adding the various code and hardware examples I have used for a basic home monitoring and control system that can be built with a little bit of effort and commonly found components. Watch this space!