ESP 9266 Control of 433MHz Switches

Lets look at what it does first:

SSID: Steele
PW: Piwehavelotsof. to connect to the esp8266 web server.

ID: light
PW: makeBright

Hardware to make it work



Note that the Plus (VCC) supply is 3.3 volts for the receiver and 5 volts for the transmitter.  This is because the ESP8266 expects 3.3
volts on its pins so the voltage supplied to the input pin reading the received data needs to be 3.3 volts.  5 Volts would fry the 8266.

We can give the transmitter 5 Volts on the supply as this voltage does not get to the 8266.  The greater voltage gives the transmitter
more power thus more range.

Perhaps a picture makes more sense.

Antenna  and

Original PDF

Software to make it work - Transmitter and web server software.


Arduino IDE

  1. You can do an apt-get install arduino, but it is an older version.  It is better to install from the source:
  3. Download the ARM Version if you want to run this on the Pi.  They will you ask you to donate.  You may want to consider doing this.
  4. Put the file somewhere where you usually put downloaded executables.  I put mine in a directory uniquely called "arduino".
  5. Un-compress it using tar.  tar -xvf.  
  6. This will create a new directory, arduino-1.8.3.  Or perhaps something larger as time passes.
  7. The contents of this directory are:

    -rwxr-xr-x  1 pi pi     946 May 31 16:58 arduino
    -rwxr-xr-x  1 pi pi 3293964 May 31 16:58 arduino-builder
    drwxr-xr-x 13 pi pi    4096 May 31 16:58 examples
    drwxr-xr-x  4 pi pi    4096 May 31 16:58 hardware
    -rwxr-xr-x  1 pi pi    9713 May 31 16:58
    drwxr-xr-x  4 pi pi    4096 Apr  7 16:10 java
    drwxr-xr-x  4 pi pi    4096 May 31 16:58 lib
    drwxr-xr-x 21 pi pi    4096 May 31 16:58 libraries
    drwxr-xr-x  6 pi pi    4096 May 31 16:58 reference
    -rw-r--r--  1 pi pi   82397 May 31 16:58 revisions.txt
    drwxr-xr-x  4 pi pi    4096 May 31 16:58 tools
    drwxr-xr-x  3 pi pi    4096 Mar 20 17:30 tools-builder
    -rwxr-xr-x  1 pi pi      86 May 31 16:58

  8. You can run the install script sudo if you wish, but you don't have to.  You can just run the arduino program.  ./arduino and after a bit you will get something like the following.

ESP8266 Board Manager for Arduino IDE

Libraries we need

These are part of the ESP 8266  base - we don't need to add these.
<ESP8266WiFi.h>    Supports the wifi connection
<WiFiClient.h>  Supports a wifi connected client.

<ESP8266WebServer.h>  Web Server Module

We need to add these:

<RCSwitch.h>  433 MHz receiver/transmitter

<DHT.h>  Temperature/humidity sensor - ask about this later if you care.

Add library by: (

Getting the Switch Codes

Normally we simply push a button but as seen above we have software to do this for us.  But what does the software have to send

The RCSwitch.h library comes with an example that you will find in the directory:


There are two file in here:

The ReceiveDemo_Advanced program calls the output code.  If you run this on the Arduino, the Receive... program seems to find the output program.  On the ESP8266 it does not.  So I just combined the two into a single file.  That works.


Output from the receive program

I used the binary values.  Bolded here.

To get these I held the remote next to the receiver and pushed a button and got:

Decimal: 5147919 (24Bit) Binary: 010011101000110100001111 Tri-State: not applicable PulseLength: 308 microseconds Protocol: 1
Raw data: 9570,306,883,880,303,295,890,294,888,876,310,871,313,869,315,285,897,870,314,288,892,293,888,295,889,293,890,874,313,286,899,868,315,283,901,284,897,286,895,287,902,864,317,866,318,864,321,862,319,
Decimal: 5147915 (24Bit) Binary: 010011101000110100001011 Tri-State: not applicable PulseLength: 308 microseconds Protocol: 1
Raw data: 9566,308,878,888,294,304,881,303,884,883,301,881,303,880,303,295,887,880,304,295,890,293,889,294,887,296,891,876,304,294,893,875,307,291,894,290,891,291,893,291,891,876,306,292,893,873,307,876,303,

Copy the binary values and put them into the transmit program discussed above.  The array variable sockets contains the codes.

char sockets[20][25] = {
"010101101000110100001111",    // On
"010101101000110100001110",    // Off ...

There are 10 switches in the system and 20 codes.  On and off for each switch.

About the temperature/humidity sensor.  It is an DHT22.  More in another presentation.