Using Software to Control Real World Things
Goals⌗
To produce a distributed logic system powered by a master pi to control slave nodes scattered about the house. The Master will take inputs from sensors and buttons to control real world objects. I want an API for all the things and a dashboard. As of 2024-02-17, it just controls a pair of led lights in my room. I want it to control power to other pis and fans. Maybe some other things. Update on 2024-05-08, I’ve moved to using ESP32/8266 devkit boards flashed with tasmota for the controllers instead of the pis.
The Project⌗
- A Raspberry Pi 4 1G running rasbien for nodered to function as a master node
- A Raspberry Pi Zero 2 running raspbien for nodered to function as a slave node and doing the actual control of things
- A t-cobbler to break out the gpio for easy access
- A breadboard to connect things
- Some relays and switches
- Some optocouplers to invert the high level 3.3v signal to ground signals for the relay boards (optional if relay boards can use high level inputs and are cool with 3.3v logic)
- ESP32 and ESP8266 devkit boards, particularlly the nodemcu 8266 and ESP-WROOM-32 devkits.
My nodered flow is still somewhat evolving but the features it provides right now is:
- Debug buttons
- Physical button inputs
- A dashboard to control things
- An API
- Latching logic for the relay outputs
Node-Red Flow for RaspPi Zero 2 | Node-Red Flow for my backup Drives
Phase 1⌗
The room lights are functional. I have 3 icons on my desktop that I can double click and have them do something, one for each set of lights and one to turn on both at once. I even put a button on my desktop to one-click the desk lights.
At the moment, the nodered flow is running on the slave pi because I had issues with latency and broken network connections with the master pi. The master pi was great as a proof of concept since I didn’t need any additional software on the slave pi, just gpiod (?) to enable remote gpio usage. I wanted to keep all the flows on one device to make it easy to modify and control. I may use the master to run indicator leds but leave the riskier tasks to cheap pi zeros. Like, potential acidental frying of the zeros. I’d like to also intergrate Pi Picos into the fun. Maybe as a second control system but I’d like to have some sort of software control on a host PC that doesn’t involve so many extra python dependencies.
Phase 2⌗
Introducing Home Assistant, esp8266 and esp32 devices.
I have discontinued using my Pis for favor of the ESP8266 modules. I bought a few of these nodemcu modules and have one running my bedroom lights and one setup to turn on my server’s backup drives.
These modules are flashed with tasmota and configured to connect with Home Assistant over mqtt.
Custom tasmota firmware⌗
while playing with these modules, I discovered there’s some things the stock firmware doesn’t do so I downloaded the tasmota source and fired up vs-code which promptly installed a program to one-click build the source and flash connected esp modules.
“Completed” projects⌗
Bedroom Lighting⌗
I used a esp8266 coupled to a dual relay module to control a set of led lights via pushbutton input and remote input from my phone and computer. Currently runs tasmota.
3.5mm audio jacks for the external buttons. No plug on the box for the lights and incoming power. That bit is external. An ESP8266 devkit. Dual 12V Relay Module. 5V Regulator. Solderless Breadboard. Project Box
Remote Pi Power Switch⌗
I have a few Pi4s sitting in a cluster case that I want to be able to remotely turn on with home assistant instead of one of those cloud based plugs. This box will support 4 Pis or whatever I plug into the 4 usb-c ports on the back.
4 USB-C plugs, soon to add a DC jack, Quad Relay module, an ESP8266 devkit, push toggle power switch, and power and status leds. May add 4 leds for relay status. Solderless Breadboard. Project Box.
Remote Switch for my Backup Drives⌗
A ESP8266 controls power to my backup drives. The controller powers a optoisolator that controls power to a Xbox 360 PSU, like how a PC PSU turns on. This PSU supplies 12v power to the drives and a powered USB Hub. There’s a script on the computer the drives connect to that will toggle the power “switch” on the controller before and after the backup operation.
The whole purpose is to keep the drives offline until they’re needed and prevent any malware from finding them, should one find it’s way into my linux server. :)
Also, the controller can turn on a hdd dock after 12v has been applied for my convience. An opto is wired to the power switch of the dock.
No Pic atm, it’s all kind of a mess where it’s at.