Monday, January 02, 2017

Using a Raspberry Pi to fix a broken Ethernet mains switch

Energenie LAN Switcher

My father-in-law uses an Energenie LAN switch to remotely manage the lighting in a shed where animals are kept. This means that the animals can be monitored remotely day and night by CCTV, and the lighting can be controlled either via the local web server on the LAN Switch, or via Energenie's internet web interface.

However, it stopped working. Time to call in the Raspberry Pi.

I already control my central heating using a Raspberry Pi and an off-the-shelf relay module, so I wondered if the exact same solution would work for the shed lights. I also wondered if I could shoehorn a Pi and the relay module into the energenie casing, so I opened it up.

Inside with the old electronics - you can see scorch marks from the old board failing

It looked like there was enough space there, so I removed the old control board with the burnt out components, and the next stage was to get the software and hardware working. I had an 8 channel relay board and an old Raspberry Pi lying around, so I decided to use those.

It is a while since I installed or updated Raspbian, so I downloaded the latest version, and I have to say, it seems that there is a lot more there by default now, which is helpful. I quickly got my heating server installed and configured, and connected the relay board, and it all worked easily.


The Pi with a relay module - I'm only using 4 relays

Using this I was able to connect via the PHP web interface, or via the android app I wrote for it. It's strangely satisfying to hear relays click on and off when you press buttons on your phone.

As this is really just a quick fix I wasn't going to change the app at all, so it still gets the title "heating controls" and the "on" command is "boost" like it is for the heating.

I set the boost to put the lights on for 6 hours, so that is effectively as long as would be required in one go. The heating controller backend has no concept of "on" or "off", only timed programs.


With this all working, it was time to box it all up. This was probably the trickiest part of the project, but I managed to get the relay module and Pi into the box. I had to do a bit of filing, but it turned out to fit quite snugly allowing the Ethernet connection out the end for easy access.



Relay board wired in

Everything fitting snugly



And some photos with the cover back on



The system has been in the shed for a few weeks now, and is working perfectly. The app allows connection over the local LAN or over the internet seamlessly, depending on which network is available, and the text based protocol means that with even with only GPRS or Edge the switching is very fast.