As my office continues to evolve, the number of powered devices also continues to grow. As not all of these devices are themselves smart, I decided to take some parts I had laying around the house and build myself a ‘smart power strip’ using my favorite embedded processor, the ESP32.
Parts
- ESP32
- Relay Controller
- 5v1a Regulator
- Project Box
- 2x Outlets + Face-plate
Assembly
Assembly of the device began on the cover of the project box. From the underside, I placed the face-plate on the lid and traced an outline out of the 4 sockets, then connecting the lines to mark out the area to cut. After drilling out the 4 corners of the markings, I used a Dremel to cut out the space in the lid where the outlets would be mounted. After dry fitting the components, I cut a number of wires to length, wired up the each of the 4 individual outlets, and screwed them into the lid.
With a bundle of wires coming from the lid, the next step was to setup the high-voltage flows through the relay board. Starting with AC mains coming in from the wall, it is then broken out and distributed to each of the 4 relays on the control board. Each of these 4 relays then has its own connection both the the ESP32 processor and its assigned outlet.
Software
With all components wired up and a smoke test complete, I wrote a very simple application on top of the BleepingWiFiProvision example. With basic provisioning handled, all that was needed was a simple UDP server which decodes a 2-byte message into a pin/state command.
Using simple bash commands I was able to validate the functionality of the device by triggering each of the 4 relays:
# Pin #13 -> 1
$ echo "0D01" | xxd -r -p | nc -u <ip> 4456
# Pin #13 -> 0
$ echo "0D00" | xxd -r -p | nc -u <ip> 4456
With the super basic firmware complete I could finally build a tiny integration and add some buttons to my TouchHome Automation Dashboard, now giving me even more control of the devices in my office.


The box is currently mounted to wall, serving two independently controlled work lights and general purpose shop outlets.