This article is part of my 1000² Smart Home project. Check out the Architecture and Software and then move on to Hardware. An most importantly, check the Lessons learned and why I did what I did. There are already some first results, connecting all parts of the system.
Progress
Finally, enough pieces of the puzzle are starting to fit together in my Smart Home project, so that I can have some end to end functionality: press a button here turn on a light there, while watching the actual slider change a graphical interface. Oh, look the temperature is displayed as well. Hooray. Still need a few “cans of bug spray”, though.
First up, some nodes
Why are they called nodes anyway? Grabbing some old and new hardware prototypes, I made a basic system with a few types of nodes, what I thought was the minimum required to get started.
The node on the right most is the server or gateway node. Still using UART, hence the FT232 adaptor. It sends received packets to the raspberry pi in MQTTish format. It sends over the radio the received commands via UART, again in a MQTTish format.
On the bottom there is a simple remote node, with 4 buttons, which is battery powered.
On the left there is a PWM led driver connected to a lamp.
The left side one with the red antenna is a battery powered temperature, humidity and light sensor, of which I have a couple already.
On the top left there is a spy node, which dumps all traffic on the UART to get a check on the network. I have used this mostly on debugging.
On the top right is another LED driver, hooked up to my previously hacked lamp.
Software
I am running things on a raspberry pi, but one could also re purpose some old computer.
I setup Mosquitto as the MQTT broker, to which Node-RED connects. In fact, I am using Node-RED as a link between the gateway node on the UART and Mosquitto, with everything else inside Node-RED interracting with the MQTT server.
Also built a small dashboard, here’s part of the hierarchy
Of course, one needs a very basic front panel, quite underpopulated at the moment. (there’s also a lesson here regarding halogen lights and temperature sensor placement).
Here are the nodes used to create the interface. With the exception of the function required to get time and date from epoch time, everything else is a normal node already included with Node-RED.
Monitoring the health of the nodes is also simple – since they transmit some parameters: the time since start (uptime), the battery voltage, the gateway RSSI for each and the average time spent in the loop. The number of packets received is also logged. Behind the scenes is very simple, since MQTT allows for wildcard selection of the same parameter from all topics.
Showing below is the time since startup of every node. For now they update this value every 10 minutes, but will change to longer once things are more stable. You can see a couple of nodes were reset some time.
A tiny bit of “automation” connects 2 buttons from the remote node to the 2 LEDs, sending the ‘toggle’ command so that each press turns the light on or off.
A pair of motion sensor and light
I have a light on the hallway made of a LED strip and a motion sensor switch, pure analog stuff, to turn on when there is motion. I replaced this with a module that drives the LEDs. Yes, ugly and temporary wiring, but it is on top of a door frame where it cannot be seen…unless you are reaaaaaly tall. I have used the combination of the core module and the LED driver module, which means i can easily detach the core and take it for re-flashing, since I have not OTA update yet.
To make things more interesting, this module does not have a motion sensor attached to it. Instead, I made a separate one, attached to the ceiling. The PIR sensor (the new digital type that has no external IC) needs a higher voltage. As I said in Lessons learned, a step up converter is a bad idea. So I used the prototype PCB to build a charge pump (diodes on the bottom) and drive only the motion sensor at double the battery voltage. The charge pump is possible because I can route the internal 32 kHz clock to a pin.
The fully assembled module attached to the ceiling lamp
The two modules work through the whole system, with node red making the rules and control. I am still playing with the optimal way to control such a setup, but node RED makes things quite easy. The setup has been running flawlessly for a few days now already.
The charge pump is more visible on the motion, light, humidity and temperature sensor I have monitoring my desk. Look at those tiny tiny diodes!
Pingback: 10002 Architecture and Software – Electro Bob
Pingback: 10002 Lessons learned « Electro Bob
Pingback: 10002 Hardware « Electro Bob
Pingback: 10002 « Electro Bob