Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Babies & Children Gallery Information Free Software Reviews Blog

Home



Welcome to the website of Stewart Watkiss.

The largest section of this is is the reviews and info for days out with babies and children. You will also find my photo galleries and blog.

You can find out a bit more about Stewart Watkiss.
Any comments or suggestions contact me using my email form.

Latest Blog Entry

Safely controlling mains electricity using the Raspberry Pi and Energenie Pi-mote


It’s useful to be able to turn mains electricity on using a computer program. Whilst it’s not hard to create an electronic circuit that can switch mains voltages, if not done correctly it can be dangerous. This is where the remote control sockets can be used to create a physical barrier between the low voltage electronic circuit and the dangerous high voltage electricity in the socket. Whilst it would be possible to create a radio transmitter to control the sockets yourself I wanted to keep this simple so that it is something that could be made easily by anyone. In an earlier project Home Automation using the Raspberry Pi I opened up a remote control and used relays to emulate a button press.

Energenie Raspberry Pi remote control board (Pi-mote)

Since I created the circuit by hard-wiring across the buttons on a remote control, Energenie has created a Raspberry Pi add-on board which allows one to switch power sockets on and off using the Raspberry Pi. The board is plugged into the GPIO port of the Raspberry Pi making it easy to send messages using software.

Energenie remote control power socket

There are a few limitations to this Energenie product compared to the Bryon home automation product I had used previously. When I bought the remote control sockets I also bought a traditional remote control hoping that I would be able to use both against the same socket. This is something I did with the Bryon system where a socket was timed to come on at a certain time, but where I could use the standard remote control to override that. In the case of the Energenie product it works with the Energenie Pi board or the remote control, but not both at the same time which I was surprised by. It is possible to overcome this by only using the Pi board and relying on software and a virtual remote control (eg. on a mobile phone). Another limitation is that the only products available are sockets or a power strip, whereas with the Bryon remotes I was able to turn a light on and off as well. The main advantage is that this plugs on to the Raspberry Pi and is very easy to use whereas my earlier project was a little temperamental due to soldering onto tracks in a way that the product is not designed for.

One thing about the Energenie remote controls is that I believe they all the remote controls (including the pi-mote) are registered using a unique code. Whilst this prevents having multiple controllers for each socket it does have the advantage that a neighbour using the same system cannot accidentally interfere with your sockets. I don’t believe it adds true security as it would still be possible to create your own controller board that monitors the wireless signal and then sends the same signals it does protect against accidental triggering.

I think that the Energenie product is better for most purposes, but it would be great if dual remote could be added in future as well as some other home automation adapters.

Adding an aerial

One thing I did do to the Energenie Raspberry Pi board was to add an aerial. Without the aerial the most it could work over was about 2 meters which is not particularly useful. Soldering a 135mm long piece of wire to the board extended the range considerably.

Energenie Raspberry Pi power remote board with aerial

Energenie Software

The instructions for the Engergenie include some example python code. The code is however it is not particularly easy to use. Instead I used the Pi-remote code python module written by Amy Mather (whilst on work experience with Raspberry Pi foundation). This code makes it easy to program the Energenie Pi-mote board.

The power control web interface

The web interface uses the module mentioned above and the Python bottle web framework. The bottle web framework is a simple way to create a web application with a built in web server rather than needing a separate web server such as Apache.

The software can be downloaded using

wget http://www.penguintutor.com/software/raspberrypi/pi-power.tar.gz

or: Download pi-power.tar.gz and copy it to the Raspberry Pi home directory.

Unzip the file using

tar -xvzf pi-power.tar.gz

change to the pi-power directory cd pi-power and then run the software using:

sudo web-power.py

This will start the web interface and you can then connect to interface using the IP address of the Raspberry Pi in a web browser. It should be possible to connect from a Raspberry Pi, PC or mobile phone and click the appropriate button to turn the socket on and off.

You do need to register the socket with the controller (it not already done using the Energenie demo code). This may vary with different sockets, but the model I use involved starting with the socket in the off position (press green button until the LED is off) then holding down the green on/off button for a few seconds (until the LED starts flashing) and then using the on button on the remote.

Energenie Raspberry Pi remote on HDMI Pi

The code is dependant upon Ajax, so a fairly recent browser is needed with Javascript enabled.

No security

Please note that there is no security included in the software provided. This means that anyone on the local network (eg. your home wireless network) can turn the sockets on and off.

It’s also possible to say that by virtue of the remote being wireless it wouldn’t be too difficult for someone to capture the wireless remote control signal and create their own remote control that sends the same signal to turn it on and off.

I would however recommend adding some form of user authentication if you intend to make the remote control accessible over an insecure network (eg. the internet).

Project ideas

As the pi-mote is controlled from the Raspberry Pi it would be possible to add other triggers to switch the sockets on and off. Using other software it would for instance be possible to use sound/voice activation (using an additional microphone) or with additional hardware based on the temperature of the air or of a liquid.

Whilst the pi-mote add-on board does not use all the pins of the GPIO port it does not make it easy to connect any other devices onto the GPIO board.

Summary

Using Engergenie sockets with the pi-mote Raspberry Pi add-on board makes it safe and easy to create a project that switch mains powered devices on and off. It does have some limitations including the restriction of only 1 board controlling the socket and not being able to access the available GPIO ports, but the simplicity of connecting this to the Raspberry Pi is a big plus.

View more Blog Entries


UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site