Managing electronic devices via web with our Arduino

details

featured

Description

In remote-controlled sockets, when a key is scrambled, a coded message is sent from the transponder of remote controlled sockets to the receiver.The plan is to read and record this message and then send it wherever we want through the web.

 

Hardware Requirements

arduino_power_socket2arduino_power_socket3 arduino_power_socket4

SAMSUNG
SAMSUNG

 

Arduino Uno

Arduino Ethernet Shield

RF transceivers

Radio- Operated Sockets

 

Circuit Connections

arduino_power_socket5

 

 

What we have to do next is either by pulsing or by linking the receiver to the linein of a sound card to record the signal and decode the 0 and 1 that escape when the remote control button is pressed.

A library is used for this. You can find the link below.

                                        Library

In the zip archive you will find an arduino project  called “ReceiveDemo_Simple”. Pass it on your arduino (change the pin first with the ones you use) and open the Serial port monitor. When you press on or off you will see the encoded message! Easier does not happen! Record the number (in my case was ON 010101000001010101010101 and OFF 010101000001010101010100.

Then connect arduino to our network.

featured

 

What we will do now, since we know the number to send, is to make our Arduino webserver respond to the request with a simple page that will have two buttons on and off through which we will send the decoded message.  You can, of course, go as far as you can.

The code we used here is this:

 

include <SPI.h>
#include <Ethernet.h>
#include <RCSwitch.h>
 
RCSwitch mySwitch = RCSwitch();
 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0, 200);
 
EthernetServer server(80);
 
void setup()
{
  mySwitch.enableTransmit(10);
  Serial.begin(9600);    
  pinMode(8, OUTPUT);    
  Ethernet.begin(mac, ip);
  server.begin();
}
 
void loop()
{
 
  EthernetClient client = server.available();
  if (client) {
    boolean currentLineIsBlank = true;
    String buffer = "";  
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);   
        buffer+=c;       
        if (c == '\n' && currentLineIsBlank) {          
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.print("<FORM action=\"http://192.168.0.200/\" >");
          client.print("<input type=\"submit\" name=\"status\" value=\"On\" onclick=\"this.value=1;\"/>");
          client.print("<input type=\"submit\" name=\"status\" value=\"Off\" onclick=\"this.value=0;\"/>");
          client.print("</FORM>");            
          break;
        }
        if (c == '\n') {
 
          currentLineIsBlank = true;
          buffer="";       
        } else if (c == '\r') {            
          if(buffer.indexOf("GET /?status=1")>=0)
            mySwitch.send("010101000001010101010101");  
 
          if(buffer.indexOf("GET /?status=0")>=0)
            mySwitch.send("010101000001010101010100"); 
        }
        else {
 
          currentLineIsBlank = false;
        }
      }
    }
 
    delay(1);     
    client.stop();
  }
}

 

As you can see above I added “the library we downloaded earlier and I gave my arduino IP address 192.168.0.200 and door 80”. Change your network accordingly.  Open your browser and fill in http://192.168.0.200. If everything went well you will see the page. Pressing on or off will hear the sound of the bad. Connect a 220v device and test it. It is also important for your router to open the door 80 and use some services like DynDNS to access the circuit outside the local network. The variants that can be made are many and proportionate to the needs of everyone.

 

Note that, depending on the transmitter’s quality and antenna, you can achieve quite a large range. 

 

Here is the video:

 

 

Tags: 201802, W5100, Ethernet, Arduino, remote controlled sockets, web

COMMENTS

Please Login to comment
  Subscribe  
Notify of