In this Instructable I will show how to control a main socket using a 433mhz transmitter and receiver.
I started this project because I wanted to be able to switch my lamp on and off without using the remote that I already had for switching the mains sockets. So that if I was in another room and forgot to switch off the lamp I could do it from my phone using home-assistant.
First of all you'll need the rc-switch library (thanks to sui77 for this library and example code). You can get this from https://github.com/sui77/rc-switch
Once you have this installed you can simply load the example called ReceiveDemo_Advanced. With this example uploaded to your ESP8266 you should be able to 'sniff' the 433mhz signals from the transmitter that came with your remote socket.
Open up the serial monitor in the Arduino IDE and press a button which switched on the socket on your remote that came with your remote socket, and you should see something like this:
Received 1394007 / 24bit Protocol: 1
These are the only real import parts that you need to keep an eye out for, and you'll need to put these into the sending script to send the same data to the remote socket to switch on.
Then do the same for the off button on the remote, again make a note of the code.
This library and receiver supports the following chipsets:
Intertechno outlets
To send the code to your remote control main socket simply use the following sketch, changing the decimal code that you got from the receiver.
/* Example for different sending methods https://github.com/sui77/rc-switch/ */ #include <RCSwitch.h> RCSwitch mySwitch = RCSwitch(); void setup() { Serial.begin(9600); // Transmitter is connected to Arduino Pin #0 mySwitch.enableTransmit(0); // Optional set pulse length. // mySwitch.setPulseLength(320); // Optional set protocol (default is 1, will work for most outlets) // mySwitch.setProtocol(2); // Optional set number of transmission repetitions. // mySwitch.setRepeatTransmit(15); } void loop() { /* Same switch as above, but using decimal code */ mySwitch.send(1394007, 24); delay(2000); mySwitch.send(1394006, 24); delay(2000); }
Connected the transmitter to the ESP8266 is very simple too. There are only 3 connections again, the same as the receiver, VCC, GND and Data.
So just connect VCC to VIN and GND to GND, and then connect the Data pin on the transmitter to a GPIO on the ESP8266 board.
I used GPIO0 which is pin D3.
Then once the sketch is uploaded you should see the remote socket switch on and off every 2 second. Proof it works...