Arduino – Control 220V Lamps from Anywhere in the World

Hi,

If you’re following my email/facebook updates you know I promised more tutorials related to Home Automation.

In this tutorial we’re going to control 2 lamps with an Arduino and an Ethernet Shield. If you have an Internet connection you can control those lamps from anywhere in the world.

Watch the Video below

First make sure you watch my youtube video above, where I explain the whole process in more detail.

Parts Requiredhas_switch_parts

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Go to Home Automation Server

Click here to go to HomeAutomationServer.com to create your free account and start editing your Dashboard with 2 new buttons.  (for example: Button #1 – Desk Light and Button #2 – Desk Light)

Receiver Circuit

has_receiver_circuit_bb_final

Click here to Download the RCSwitch Library. Install it an Re-open the Arduino IDE. Then open the example “ReceiveDemo_Advanced”. Upload the code and open the serial monitor. Start pressing the buttons from the Remote you’re going to use and save them.

Transmitter Circuit

has_sender_circuit_bb_final

After you complete  the transmitter circuit. Upload the Arduino code below. (Change the user_key and the if statments as shown during the video)

Click Here to Download the Arduino Code

Thanks for watching, you can contact me by leaving a comment below. If you like this project probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

P.S. Make sure you watch the youtube video above otherwise you might not fully understand some of the steps.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

61 thoughts on “Arduino – Control 220V Lamps from Anywhere in the World”

  1. This project is working well BUT we need to now close the loop by receiving status back from the remote device.
    Specifically how can we see the status of a digital input or the value on a remote analog input. Do you intend developing the dashboard to have that capability?
    There are twitter examples using arduino but can we get that into the dashboard?

    Thanks

    Reply
    • Hi RayB,
      That’s a really good question!
      The problem with this project is exactly that, We’re never sure if the Digital Pins changed.
      And we can’t read the Pins from the Arduino. I don’t know exactly how to do that with an Ethernet Shield.

      I might integrate this project with a Raspberry Pi or Arduino Yun. Those devices were meant for that.
      The Ethernet Shield is a bit limited, it works really well as a webserver, but if you try to do some complex authentication or web requests… It’s not a good idea.

      Thanks for asking,
      Rui

      Reply
    • Hi Hans,
      thanks so much for your feedback!
      I’ve worked really hard to create the HomeAutomationServer platform.

      Have a nice day,
      Rui

      Reply
    • yes you can use from anywhere.
      Basically the arduino with the ethernet shield keeps reading your unique webpage at http://homeautomationserver.com.
      So when you change the state in your account, the arduino will also update his state.
      I’ll never know your ip address.
      Let me know if I can help you more,
      Have a nice day,
      Rui

      Reply
  2. Hello again Rui,

    I just have cloned codes of remote outlets, but the garage gates I can’t! The receiver does not detect anything! Help… how to get?
    Thanks

    Reply
    • Hi Antonio,
      What have you tried so far?
      I have no idea what’s happening I can be anything with the information you provided…

      Reply
  3. Hi Rui

    I do not understand why my transmitter does not pick up the bytes in the Arduino Serial Monitor automatically like it appears to do for you. The code has uploaded fine… I bought the same transmitters as you and have tried two different units. My remote says its 433 Mhz and works perfectly with the power units. The only thing I can think to do is try another remote but I don’t think that is the issue. Have you got any ideas what the problem could be or any suggestions to try?

    Thanks
    oliver

    Reply
    • Hi Oliver,
      You said you’re transmitter doens’t pick up the bytes?
      you meant the receiver right?
      The receiver is the one who need to receive the data when you press the buttons, and you’re right that should appear in the Arduino Serial monitor instantly.

      Reply
      • Thanks for getting back! Sorry, of course I meant the receiver, not transmitter. (I must have been at it for far too long that day!) I am hugely disappointed that I still haven’t been able to figure out what I’m doing wrong as the project has incredible possibilities!

        I have tried everything exactly as instructed but still no luck. As I said I tried different RECEIVERS,different wiring,different pins, different arduino, different remotes.. reinstalled arduino ide. Still no numbers appearing in serial monitor!
        The rx l.e.d on arduino lights when I send a number but nothing on tx.

        I really don’t want to give up the project but am going to start tearing hair out soon and have run out of ideas!
        If I bought the exact same remote controlled sockets as you, would the decimal numbers produced be the same, in which case I could use your numbers and proceed?
        or do you have any other last suggestions 🙁

        Reply
        • I can’t get mine working either. Did you have any luck getting it working? Can’t say I have gone to the extent of trying it with a new Arduino or RF receiver.

          With another sketch I am able to get data from the receiver via the analog pins but i get a lot of noise. I suspected this may be the cause of my issue so I tried it in the shed at the end of my garden, and still no joy! Very frustrating.

          Really want to get this working.

          Reply
          • In case anyone is struggling to get this working, I found rf-switch didn’t decode my remote signals, so I had to record them by attaching the receiver to a 3.5mm jack, which I then connected to the line-in of my soundcard. It was then a case of reproducing the signals using the Arduino.

            Also found my wireless dect house phones caused major interference which didn’t help matters.

  4. Hi, I have copied the example sketch in the arduino copied and pasted the key my changed my ip address and mac. However when I start the serial monitor I get the following: Connecting,connected The client is not available, restarting, error during connection, stop-connection was activated.

    I also noticed that when I press one of the buttons either on or off the key does not appear after homeautomationserver.com but only /dashboard.
    What can be the cause of that.
    Thanks for a excellent service.

    Reply
    • Hi Ben,
      Sorry for taking so long to answer I’ve been really busy for the past few days…
      Please try again, but don’t change the ip address and mac.
      You should only change the user_key.

      Tell me what you see on the serial monitor…
      Have a nice day,
      Rui

      Reply
      • Hi Rui, Reading Serial monitor: Connecting,connected, client not available.
        restarting, current state; error during connection, stop connection was activated.
        Then the process start all over again. As it should. But it keeps on telling me client not available. By changing IP and mac I meant I put in my IP and mac. Are you saying I must leave the orginial mac and ip as per sketch. can you diagnose from that was is wrong?

        Thanks
        Ben

        Reply
          • Good morning Rui,

            I did what you said, and put the original mac and ip in the provided spaces.
            Makes no difference.
            Still the same message on aerial port.
            Client not available.
            I copied and pasted the sketch from gibhub because
            I dont see any other means of down loading.
            But I don’t think that is the problem.

            If it was! The IDE would have rejected it.
            I sincerely hope we can come up with a solution. Because I like this sophisticated system. Want to put a webcam on it as well.
            Regards

            Ben

  5. Hi , your project is really cool . I want to make a device like you build . BUT i have a wi-fi sheild instead of Ehtanet sheild .

    My question is, can your project be done with a wi-fi sheild ??

    i have no experience of arduino wifi/Ethanet sheild . so please help me out .

    Reply
  6. loading HAS_Control_220V_Lamps.ino – bug
    sketch_nov22a:55: error: ‘RCSwitch’ does not name a type
    sketch_nov22a.ino: In function ‘void setup()’:
    sketch_nov22a:68: error: ‘mySwitch’ was not declared in this scope
    sketch_nov22a.ino: In function ‘void updateState(String)’:
    sketch_nov22a:121: error: ‘mySwitch’ was not declared in this scope
    sketch_nov22a:121: error: expected `)’ before numeric constant
    sketch_nov22a:126: error: ‘mySwitch’ was not declared in this scope
    sketch_nov22a:131: error: ‘mySwitch’ was not declared in this scope
    sketch_nov22a:136: error: ‘mySwitch’ was not declared in this scope

    Reply
  7. Hello! Downloaded RSSvich, HAS_Control_220V_Lamps got user_key. The system worked very well for many days, is stable. Who does not work, change user_key does not help. On the monitor, the following information
    connecting…
    connected
    disconnecting.
    Current state: !DOCTYPE html
    connecting…
    connected
    disconnecting.
    Current state: !DOCTYPE html
    connecting…
    connected
    disconnecting.
    Current state: !DOCTYPE html
    Website https -github-com where I downloaded the library is now blocked in Russia. Why does not HAS_Control_220V_Lamps do you think? whether this is due to the blocking of the site Website https-github-com ?

    Reply
  8. often on the monitor displays a message
    Current state: html style=”height:100%”
    connecting…
    connected
    The Client is not available.
    restarting…
    Current state: Error during connection, stop_connection was activated

    Reply
  9. Hi Guys
    i’m working on home automation system project using arduino Yun, i already created an andriod application and special website to control home devices using arduino micro-controller, i successfully controlled in my LAN but i want to control them from anywhere in the world, i saw some tutorial and web sites that describe the controlling arduino Yun remotely but all ways were difficult for me and i couldn’t fix this problem, i seeing that you are using Arduino Uno with Ethernet shield for controlling devices from any where, i want to ask you if i use the arduino Yun what steps should i perform for controlling devices remotely? please help.

    Reply
  10. Hello Rui….
    Fantastic tutorial thank you.
    I have a request, please. I would like build devices HomeKit compatibile using arduino Ethernet (by cablerai) and relays.
    At moment I have homebridge running on Mac. In the future I’ll move to Raspberry. Now I’m controlling the Nest and I want add Arduino Ethernet and some relays .
    Can you publish a tutorial about? YouTube shows some video about, but no on want share the how to… I’ll trust you’ll do it.
    Thank you so much.

    Reply
  11. Your eMail about Home Automation Server…
    There are a lot of alternatives already running on RP and a lot of other “iot” devices (Arduino, RP, ESP8266, Particle)
    Let’s say Blynk, a cloud server but you can run a private local server too.
    You can pilot your devices from iPhone or Android.
    If you’re hurry to control your light from anywhere, look at Blynk

    Reply
  12. Dear
    Thank you for your contact. I catfish long time in electronics, but short in using Arduino applications. I’m willing to actively participate in your action.

    Best Regards
    Blagoja

    Reply
  13. Hi Rui and Sara.
    This last comment of Sara’s is confusing. I can see that “homeautomationserver.com” is working.

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.