Controlling Remote Sockets with a Raspberry Pi and Node-RED

I wanted to be able to remotely switch a lamp on and off, mostly to make it look like we are in. We’d previously used a simple timer switch but they kept breaking plus I didn’t like the way they switched on at exactly the same time every day.

There are a lot of off the shelf options to do this but I had a budget to stick to.


I found a few posts and threads talking about some remote sockets which are available in the UK from Maplins (5 pack for £29.99, sometimes reduced to £19.99) and Wilkos (3 pack for £15). These appear to be the same sockets in branded packs.

To control them with a Raspberry Pi 3 I used the RF transmitter from this kit on Amazon, which cost £1.08. I wasn’t very hopeful that this would work as I’d previously tried to use the RF kit to communicate between two arduinos with very limited success, with the Raspberry Pi however it all worked straight away.

I soldered a 17cm piece of wire onto the transmitter as an aerial.

To connect it to the Raspberry Pi connect the VCC pin to a 5V pin on the pi, the GND to a ground pin and the DATA (on the version I have this is printed backwards – ATAD!) to a data pin on the Raspberry Pi.
RF Transmitter

NOTE I used Raspberry Strogonanoff for this project which uses WiringPi-Python which has different pin numbering to the standard Raspberry Pi pin numbers. This is all detailed on the Strogonanoff github page. The transmitter fitted fairly neatly into the Raspberry Pi case, if the top is not pushed on all the way.

Pi with transmitter


The trickiest part of this project was installing WiringPi-Python correctly, this didn’t seem to work when I followed the instructions on the Strogonanoff page, instead I had to follow the Manual Build instructions on the WiringPi Python page.

Once this was done it all worked straight away using the command:
sudo ./ --channel 1 --button 3 --gpio 0 on

Channel refers to the channel on the back of the remote, button refers to the socket number and gpio is the WiringPi pin number.

Node-RED integration

It’s really easy to hook this into Node-RED. It just requires an exec node with the command

sudo /home/pi/raspberry-strogonanoff/src/ --channel 1 --button 1 --gpio 0 on

node-red sockets This example switches 2 lights on at dusk and then off again at 10.30pm on weekdays and 11pm at weekends. The lights can also be controlled through a Node-RED UI dashboard and MQTT. It’s pretty easy to use Tasker, AutoVoice and the MQTT tasker plugin to add voice control to your sockets.

The flow is available here: 

Add a Comment

Your email address will not be published. Required fields are marked *