Visit this project on GitHub.This post is part of a series:
Today we’re going to finish the Arduino Power Strip – or at least bring it to a state where it’s usable for now and can be controlled using Home Assistant. There is also an issue we need to address.
Before starting with the low voltage wiring, I added a separating wall made from plywood between high voltage side and low voltage side to serve as an additional barrier if a wire might come loose. First I wanted to screw the plywood in place using small wooden blocks I glued to it, but after the first block split I decided against that and just glued everyhing in place.
I then wired the relay board to the outputs of the Arduino Nano and connected power from a barrel connector to the Arduino and the board. The 12 V supply is fed in via the connector and from there into the VIN pin of the Arduino as well as the relay power input of the relay board. The 5 V generated by the Arduino powers the optocouplers and LEDs of the relay board. And before you’re complaining: the electrical tape is temporary and will be replaced with proper heat-shrink tubing.
The Arduino is mounted to the base plate using a 3D-printed holder and 2 × 10 mm (≈ 5/64″ × 3/8″) wood screws, a 10 × 13 mm (≈ 3/8″ × 1/2″) cutout in the side wall makes sure that a USB cable can be connected. The OpenSCAD file which is based on an existing model from Thingiverse is in the GitHub repository of this project.
To mount the barrel connector for the low voltage power supply I 3D-printed another small part because the side wall is too thick to mount the connector directly to it. The file for this part is also in the GitHub repository.
Finally I mounted the other three side walls as shown in the previous post of this series.
Integration into Home Assistant
To control the power strip from Home Assistant I used the Modbus integration together with the Arduino Modbus Library. The Raspberry Pi I’m running Home Assistant on connects to the Arduino inside the power strip via USB, but I might replace that with a proper RS485 bus in the future to be able to connect more devices.
The software for the Arduino is very simple, it’s just implementing eight digital output channels (called coils in the Modbus world) that control the eight relays. Have a look at the GitHub repository for details.
A problem with the current design that I discovered pretty quickly during my first tests is that the relays really like to get stuck in the ON position when they are switched with a load connected. This happened almost every time for devices with rather large power supplies (like a PC) but basically never for smaller loads (like a LED bulb or a USB power supply).
It’s currently not a huge deal for me because I mainly use the power strip to switch lights – for larger loads I switched to commercial wireless sockets. In the future I might try to replace the relays with solid state relays or maybe better relays that are designed for larger currents, that should solve the problem. I will keep you updated on any future improvements :-)