Categories

Network and Arduino sockets

 

The user control 230 V socket outlets with Arduino

 

 

Example provides a method of controlling access to electrical outlets automatically or remotely using Arduino. With this solution you can apply the basic elements of a smart home.

 

In the example, we used the following elements:

 

At the beginning of the library you want to add to the environment of the Arduino (Sketch -> Include Library -> Add .ZIP Library...).

 

Connecting the receiver

To control the outlet, you should consider the codes with the remote control included in the nest. For this we will use a receiver connected to Arduino.

 

Pina receiver

 

PinDescription
1

VCC - power

2DATA - pin-code data
3DATA - pin-code data
4GND - ground system

 

 

 

Now you need to connect appropriate contacts of the receiver with the Arduino:

 

Connection

 

Pin ArduinoThe Pin code of the receiver
GNDpin 1 - GND
D2pin 2 or 3 to DATE
+5 Vpin 4 - VCC

 

Then the software part. For example, open ReceiveDemo_Advanced from the included library (File> Examples> RCSwitch -> ReceiveDemo_Advanced) and upload it to the Arduino.

Now using the monitor's serial port (Tools> Serial monitor) the ability to read codes from the remote . The resulting values should look like the screenshot below:

 

 

The first two lines is a switch button, socket, the following two button, mute button.

 

The connection of the transmitter

To connect the sensor to Arduino, you should familiarize yourself with the conclusions of the contacts of transmitter:

 

Contacts transmitter

 

PinDescription
1DATA - pin-code data
2VCC - power
3

GND - ground system

 

 

 

Now you need to connect appropriate contacts of the sensor with the Arduino:

 

Connection

 

Pin ArduinoThe Pin code of the transmitter
GNDpin 1 - GND
+5 Vpin 2 - VCC
pin 10pin 3 - DATE

 

 

Used program code

 

#include  

RCSwitch mySwitch = RCSwitch(); 

void setup() 

{ 

Serial.begin(9600); 

mySwitch.setPulseLength(325); // Value read from the serial monitor 

mySwitch.enableTransmit(10); // Pin connected to the transmitter 

} 



void loop() 

{ 

mySwitch.send("000000000000010101010001"); // binary Code of the first button 

delay(5000); 

mySwitch.send("000000000000010101010100"); // binary Code of the second button 

while(1); // Infinite loop 

} 

 

The above code includes in the socket, then after 5 seconds it turns off.