I recently bought a 3 pack of 433Mhz sockets from bangood and set about building an RF blaster to control the sockets via Home assistant. These devices are considerably cheaper than other such devices such as the Belkin Wemo or TP Link SmartPlugs.
The downside is that the communication is only one way in that the switches will not report back to Home assistant if they are operated manually.
For the price though, they are ideal for devices such as bedside lamps or side lamps.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What Your Going to Need.
All of the parts you need can be purchased from Bangood or AliExpress, I've provided links to Bangood for you
Soldering iron and solder
3 short Dupont leads, Black, Red and Yellow
Arduino IDE Installed and ready to go by Arduino
Overview of Arduino install for ESP8266 by Traiker J
The rc-switch library by Suat Özgür
WifiManager by tzapu
PubSubClient by Nick O'Leary
Installing Arduino Libraries by MertArduino
Step 2: Assemble Your Decoder
The RF Modules are shipped as a seperate transmitter and receiver modules.
You can see these modules above in the first image, the larger module on the left is the Receiver we need to start with this module as we need to read the codes from the remote that came with the sockets.
To start with, solder the headers onto Wemos D1, an easy way to do this is to insert the header pins into the breadboard, pop the Wemos board onto the headers and solder them in place. I start with the top and bottom pins first and then do the rest once they have first cooled.
Once you have finished soldering, mount the receiver module onto the breadboard.and hook up the wires...
Wemos Colour Receiver.
3V3 Red Vcc
D3 Yellow Data
GND Black GND
Step 3: Grab the Codes From Your Remote.
Start the Arduino editor and make sure it is connected to the correct serial port
Change the board to "WeMos D1 R2 & mini"
Now load the example sketch ReceiveDemo_Advanced from the rc-switch library.
Upload the sketch to your Wemos board, and open the Serial Monitor.
Press each button on your remote, You should see output similar to the above image.
Copy and paste the data for each button press.
Decimal: 9429772 (24Bit) Binary: 100011111110001100001100 Tri-State: not applicable PulseLength: 143 microseconds Protocol: 1 Raw data: 4438,394,161,122,450,118,451,118,453,404,158,413,164,406,165,406,159,412,161,410,161,410,163,119,454,114,457,112,456,402,163,408,166,117,453,116,455,113,453,116,455,403,161,410,162,120,455,113,460,
Received value: 9429772
Of this data the info we are interested in is as follows
Decimal: 9429772 (24Bit) (Which will be different of each button on your remote)
(24Bit) is the data length, I've never seen myself anything other than 24Bit but I'm sure there are variations.
Protocol: 1, The protocol length defaults to 1 so no need to set unless it is different.
Step 4: Build the Transmitter
Power up your Soldering Iron.
Insert an Antenna into the Ant pin on the transmitter board and once your iron is hot enough solder the antenna in place.
Unplug the USB lead from the WeMos module.
Remove the receiver board from the bread board and replace it with the transmitter.
Check you hookup wires are going to the correct locations on the transmitter.
WeMos Colour Transmitter
5v Red VCC
G Black GND
D3 Yellow Data
Reconnect the USB lead to the WeMos module
Download the sketch SendDemo.ino and save to a folder called SendDemo, open it up in the Arduino IDE
You now need to edit the following lines:
Line 12, set the Pulse length
Line 13-18 Set the on/off codes for each socket
Line 19 set the bit length
Line 20 set the protocol if needed
Save the sketch and upload to the WeMos, if all is well your RF Sockets should start turning on and off in turn on a 1 second interval.
Step 5: The Final Sketch
Download the rfBlaster.ino sketch and save it to a folder called rfBlaster, then open in the Arduino IDE.
You now need to edit the following lines.
Line 20: #define R433PULSELENGTH 143
Change to suit your pulse length
Line 21: #define R433BITLENGTH 24
Change in line with your devices needs
Line 26: const PROGMEM char* MQTT_USER = "MQTT User";
Change "MQTT User" to the user name used to connect to you MQTT server and
Line 27: const PROGMEM char* MQTT_PASSWORD = "MQTT Password";
Change "MQTT Password" to your MQTT servers password
Line 79: WiFi.hostByName("your_mgtt.server.co.uk", MQTT_SERVER_IP);
Once you have given the sketch the once over, verify it, correct any errors if needs be then save the sketch and upload to your WeMos.
Step 6: Connect Your RfBlaster to the Wireless Network.
Open up the Serial Monitor in the Arduino IDE, change the baud to 115200 and hit the reset button on the side of the WeMos.
If this WeMos has never had a sketch uploaded to it using the WiFiManager library you should be seeing something similar to this...
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: SET AP STA
*WM: Configuring access point...
*WM: AP IP address:
*WM: HTTP server started
If not and you would like to start from scratch, you will need to uncomment line 63: //wifiManager.resetSettings(); and resend the sketch to the WeMos, then comment the line out again and resend once more to the WeMos.
Now we are set to connect the rfBlaster to your local wireless network.
Using a smartphone or a pc with a WiFi adapter bring up the list of available networks.
Click on the network named ThingMaBob and connect to it.
You will then need to Authenticate, on Android clicking the Authenticate icon at the top of the screen will take you to the pages built into the WiFiManager, you can now select your local network and then enter your wifi key.
When you click save the settings will be written back to the WeMos so that it will automatically connect on boot.
The WeMos will now reboot and connect to your local WLAN and attempt to connect to the MQTT server.
Step 7: Adding the RfBlaster to Home Assistant
I separate all of my devices into separate files which I then include in the main configuration.yaml.
Please add these devices to wherever you keep yours.
You will need an entry for each socket you have, you can alter the names to whatever you like, but you must make sure state_topic and command_topic match what you entered in the rfBlaster sketch on lines 28 to 33. Please also make sure you increment the number in the payloads for each device.
Finally run a test to make sure everything is ok with your new entry
/usr/local/bin/hass -c ./ --script check_config
If all appears ok restart hass
service hass-daemon restart
You should now see 3 new switches in the home assistant gui.
Check you can toggle the switches from within Home assistant.
Step 8: Boxing It All Up.
Take one of the project boxes and pop the back off
Plug your USB lead into the WeMos
Peel the back off of the sticky pad on the back of the breadboard and sit it in the project box pushing it down firmly and holding in place to allow the adhesive on the back of the breadboard to grab.
I found I needed to bend the transmitter over somewhat as it sat proud of the top of the box.
Dress your cables so they are reasonably tidy and wont make fitting the back a pain.
Fit the back, and give your project a final test in its fully assembled state and if all is working deploy to where ever you need.