So, as part of the big (to little) office move in 2019, I had a lot of electrical equipment to squeeze into a very small space.

This meant being ruthless is wrapping cables together, routing them under and behind my desk and shelving and generally trying to hide plugs, sockets and wiring away. This, of course, means that getting access to plugs or power strips to physically turn equipment on or off is completely impractical.

As a point of reference, there are almost 50 UK mains plugs in use in this room…

It would be irresponsible, costly and rather dangerous to leave all of them powered on all of the time, so I made the decision to have them all remotely controlled by Energenie radio-controlled power strips. I had a couple of these elsewhere in the house (handy to turn the TV/Hifi off without having to reach around the back for the socket!), and, having seen that an open-source project existed to interface with them, thought they would make a good basis for a home automation system without all of the vendor lock-in or cloud hosted server interfaces.

There are single socket versions available, but for my use, the 4-way power strips are the most efficient use of space - each socket being individually controlled; on/off, via a pre-programmed RF remote.

Energenie also offer a specific add-on hat, for use with a Raspberry Pi, but a lot of people have found that the generic Hope RFM69 radio module (which is an SPI bus-interfaced radio module) works just as well.

Duplication of remote control functionality

One of the problems with the Energenie RF system, is that out of the box, the handsets are pre-programmed with device codes which you pair with the sockets. It's not possible to read what those codes are (which would be necessary, in order for the power sockets to respond to another radio device), and there's nothing on the handset or PCB to say what those codes are.

There is a method to analyse the radio signals from the remote, with a software defined radio, but as I learned, there is something going on between the handset and power sockets that means you are not guaranteed to replicate the device codes perfectly using a different radio module.

As it turned out, needing to do that wasn't strictly necessary; putting the power sockets in their “pair with handset” mode, and sending the power on signal from the Pi radio module was enough to get the power socket to pair with the slightly different signal that the Pi was sending. Et voila! Power sockets now able to be controlled by the Pi…. of course, I had to replicate this pairing for each of the power strips I owned (14, at last count), since each one was responding to a different device ID, but once that was done, each strip and socket could be addressed individually.

So I technically had a way of controlling the sockets, but I needed a way of interacting with that functionality…. keeping track of a dozen or more remote controls was not what I wanted to do.

I had done a little bit of libSDL programming for my Cosworth ECU interface project, and had since done a little more at work, so I thought I could knock together an interface using a simple touchscreen board for the Pi.

So this is what I came up with:

Scrollable pages of buttons that are mapped to individual power sockets on the remote control power strips. The action of the button can be toggle from on to off by the middle icon on the bottom row (green for power-on, press to toggle to red and set to power-off).

I also added a couple of power monitor plugs:

…these are strictly broadcast-only devices which send a burst of power metrics over the same RF signal as the power sockets, approximately every 60 seconds. The PyEnergenie project also had support for these, so I was able to pull this data in using the same RF module used for controlling the sockets, displaying it on the touchscreen at the press of a button:

This screen let me monitor the power use of all of the sockets in the room in (almost) real time. There is a lag for the power monitor sockets to re-broadcast their data (it's every 60 seconds or thereabouts), but it's good enough to see the loading on the 4 wall sockets in the room, along with the various power strips that run from them.

More content will go here, but for now:

  • blog/personal_diy_pi_powercontrol.txt
  • Last modified: 2019/10/23 09:09
  • by john