RF Outlet Remote Control with Raspberry Pi

A subset of one on the projects I am working on with the Raspberry Pi is the ability to control miscellaneous RF items. A great start into this endeavor is radio frequency (434 MHz) remote control of a power outlet. The wireless outlets I used for this project were Etekcity’s Auto-Programmable Outlet Light Switch; Amazon carries the Etekcity ZAP 5LX for around $30.00.

Etekcity Wireless Outlet

Getting Started, Capturing the Codes:

Before I could do any work on the RF controller, I had to capture and decode the protocol from the wireless remote control. An effective way to do this was to breadboard a 433MHz RF Link Receiver and attach it to my PC soundcard. A good explanation on how to do this is at davehouston.org: Capturing IR and RF Codes.


 RF Link Receiver- 434MHz         rf_soundcard_interface


On the RF Link Receiver, I only used three pins; 1 (GND), 2 (DATA OUT) and 5 (5VDC). An antenna was not needed for me to capture a clean signal to decode from the wireless remote control.


After looking at the captured waveform, I was able to determine that each message contains 24 bits, and a sync pulse. Each bit is represented by a short high – long low (digital value 0) or long high – short low (digital value 1). The sync pulse is a short high – very long low. By looking at the number of samples contained in each pulse, I can get an approximate value of the duration; (samples/48000 (sample rate)) * 1,000,000 = duration in microseconds (us). Note: long duration ~= 3 * short duration. The message is then repeated several times for each button push.

0 9 188us 27 564us
1 27 564us 9 188us
SYNC 9 188us 270 5625us

I have captured the waveforms for the on/off values on all five channels and have listed the decoded bits below. the first 8 bits is the preamble, or extended address range, and is the same for every channel: 01010101. The next 12 bits is the address for channels 1-5, and the last 4 bits is the on/off command.

000101010011 : CHAN 1 0011 : ON
000101010011 : CHAN 1 1100 : OFF
000101011100 : CHAN 2 0011 : ON
000101011100 : CHAN 2 1100 : OFF
000101110000 : CHAN 3 0011 : ON
000101110000 : CHAN 3 1100 : OFF
000111010000 : CHAN 4 0011 : ON
000111010000 : CHAN 4 1100 : OFF
001101010000 : CHAN 5 0011 : ON
001101010000 : CHAN 5 1100 : OFF

Controlling the RF Outlets, Hardware:

Now that we have the protocol worked out for the controller, we can attach the hardware to the Raspberry Pi. I am using a simple 4 pin 433MHz RF Link Transmitter that can be directly attached to the unit with no external components.

RF Link Transmitter - 434MHz       rf_transmitter_interface

Controlling the RF Outlets, Software:

This program requires Wiring Pi: GPIO Interface library for the Raspberry Pi to make it easier for setting up and using the Pi GPIO pins. After you have installed WiringPi. you can test it with the following command.

gpio -v && gpio readall

Once WiringPi is successfully installed, copy the following source code into a file named etekcityZapTx.c and compile.

mkdir source
cd source
nano etekcityZapTx.c

Double click the source code to get the full listing. Copy and paste into nano and save.

gcc -Wall -o etekcityZapTx etekcityZapTx.c -lwiringPi

And now we can test the program. On my setup, using 5VDC and no antenna on the RF Link Transmitter, I was successfully able to switch the outlets in a 20X20 foot room. For better range, the RF Link Transmitter can operate up to 12VDC with an external antenna; 433.92MHz @ 1/4 wavelength vertical = 6 1/2 inches, 433.92MHz @ 1/2 wavelength vertical = 31/32 inches.



The following image shows the original captured waveform from the Etekcity remote control and the Raspberry Pi RF Link Transmitter hardware and code. While they are not a perfect match, there is enough flexibility in the outlet decoders to accept the commands.


External Resources:

Wiring Pi: GPIO Interface library for the Raspberry Pi
davehouston.org: Capturing IR and RF Codes


RF Link Transmitter (434MHz) – Datasheet
RF Link Receiver (434MHz) – Datasheet
Etekcity Self-Learning Remote Control Outlet Switch – Manual

Shaun Bennett has written 6 articles

3 thoughts on “RF Outlet Remote Control with Raspberry Pi

  1. Dale Farnsworth says:

    I’ve been duplicating your Etekcity ZAP 5LX work on an esp8266 (nodemcu devkit 1.0) using the arduino platform for esp8266. Your work has been very helpful. Thanks!

    Here’s the 24-bit address command I see for my unit:
    on 1 0100010101 0101010011 0011
    off 1 0100010101 0101010011 1100
    on 2 0100010101 0101011100 0011
    off 2 0100010101 0101011100 1100
    on 3 0100010101 0101110000 0011
    off 3 0100010101 0101110000 1100
    on 4 0100010101 0111010000 0011
    off 4 0100010101 0111010000 1100
    on 5 0100010101 1101010000 0011
    off 5 0100010101 1101010000 1100

    So, it appears to me that there is a 10-bit preamble/extended address, followed by a 10-bit switch selection address, followed by the 4-bit command.

    I only have the one ZAP 5LX to try, so it’s great to compare it to yours.

    Thanks again,

    1. Anon says:

      To provide more data. I also believe that it is 10,10,4
      0101000001 0101010011 0011
      0101000001 0101010011 1100
      0101000001 0101011100 0011
      0101000001 0101011100 1100
      0101000001 0101110000 0011
      0101000001 0101110000 1100
      0101000001 0111010000 0011
      0101000001 0111010000 1100
      0101000001 1101010000 0011
      0101000001 1101010000 1100

      1. Anon says:

        Definitely 10/10/4. My data:

        0100010001 0101010011 0011 ON1
        0100010001 0101011100 0011 ON2
        0100010001 0101110000 0011 ON3
        0100010001 0111010000 0011 ON4
        0100010001 1101010000 0011 ON5
        0100010001 0101010011 1100 OFF1
        0100010001 0101011100 1100 OFF2
        0100010001 0101110000 1100 OFF3
        0100010001 0111010000 1100 OFF4
        0100010001 1101010000 1100 OFF5

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">