loading
With Arduino you can really make so many fun and useful projects, especially to facilitate some tasks at home. In this article we will see how to use the Arduino to remotely turn on a lamp, or any device that is connected to the outlet of our home.
Let 's see what devices are needed to make this project:

hardware

1 x Arduino Uno cost 12 Euro, sold on Ebay
1 x ENC28J60 Ethernet card cost 5 euros, sold on Ebay
1 x Relay 220 V 10 A cost 3 Euros, sold on Ebay
1 x Ethernet cable 1 meter cost 2 Euro

software

Arduino IDE
Library for ENC28J60 https://github.com/jcw/ethercard
Sketch code lamp relay + + WebServer

Step 1: What is a relay?

A relay, from the external point of view is a simple switch capable of passing current or not. This phenomenon occurs through a physical principle, based on the coupling magnet that is generated through a passage a small excitation current, which is supplied by the Arduino. There are two configurations with regard to the relay:

1. NO (Normally open)
2. NC (Normally closed)

These two configurations differ only in the code you need to write in Arduino. The first configuration, in the case of switching off the relay, no current is passed (the circuit is open) and that the lamp is turned on you need to get out of an Arduino signal "HIGH". The NC configuration is dual, in case the relay is not energized, the current flows in the device and that the lamp is off, you need to do to get out of an Arduino signal "LOW".
To recap from the point of view of the code:

NO configuration

digitalWrite(relay,LOW); // Lamp off
delay(1000);
digitalWrite(relay, HIGH); // Lamp on


Configurazione NC

digitalWrite(relay,LOW); // Lamp on
delay(1000);
digitalWrite(relay, HIGH); // Lamp off

For those who wish to learn more about how this circuit element, you can visit the website of Wikipedia, which talks about the various types of relays.

<p>Hello, I have connected my arduino to the internet and uploaded the program but i only says &quot;Getting IP via DHCP&quot;, after 5 minutes it was still the same how can i fix this?</p>
May be that your router has disabled the DHCP protocol, or the ethernet cable is not well inserted in the Arduino
<p>I already know what it is, if you use the Arduino Mega 2560 then you need to use other pins: 50, 51, 52, 53 for the ENC28J60 and you can use the relay pin on 5</p>
<p>hei, very good project !</p><p>i tried your program using ENC28J60 and its working, i can turn ON/OFF remotely from my browser.<br>but once i try to open the IP address for my Arduino from another device (my phone), it doesnt load the page.</p><p>so i assume that this code only work for local network. (cmiiw)</p><p>how can i change it so it can work online too?</p><p>thanks in advance</p>
The problem is that by default you can't access remotely to your router, but you need to perform an operation that is called port forwarding.<br>From your local network you have to open the console page of your router; move to the page of port forwarding and insert the port 80 for the TCP connection and the IP address of Arduino. Once completed this, type on google My IP address and get it. Now you can remotely switch on and off your lamp from your smartphone
<p>Hi, can i switch a bulb/lamp or led by using remote control tell me.</p><p>thanks!</p>
Hi,<br>yes you can switch on/off your lamp/led with this tutorial. The relay is able to open and close the current flow.
<p>where is the code for arduino if i want to use ENC28J60?</p>
<p>Hi!</p><p>How could i make it to work online, not only local?</p><p>Thanks !</p>
<p>The trick is use the NAT of your Router. For this purpose, you have to port forwarding the port number 80 of the IP address of Arduino. Once done this, you have to get the public IP of your broadband connection and that's all.</p>
<p>can you give me example about it?</p><p>also control from PHP</p><p>thanks</p>
<p>Do you want to turn on and off from a PHP application your lamp? </p>
<p>yes please , but online not local</p><p>i hope you can give me example</p><p>thanks</p>
<p><?php-- ><!--?php-->&lt;?php </p><p><!--?php$url = 'http://localhost/examples/httprequest/call.php';-->$url = 'YOUR_PUBLIC_IP';</p><p>$http = newHttpRequest($url, HttpRequest::METH_POST);</p><p>$http-&gt;addPostFields(array('value' =&gt; '?on'));<br></p><p>$response = $http-&gt;send();<br>echo$response-&gt;getBody();<br></p><p>?&gt;</p><p>I've not tested it, but I think should work without any problem. Of course you have to insert your public ip of your Arduino and use the second version of the code, the one for the official ethernet shield for Arduino.</p><p>If you don't know your public ip, this is a useful web site: http://whatismyipaddress.com/. If you haven't done it, you have to open the port 80 on your router for the local ip address of Arduino, to let someone else from external, to access the Arduino.</p>?></p>
<p>hii &gt;&gt;after i get the public ip and the port &gt;is there any changes in the code</p>
<p>How to use it with RN-42 bluetooth?</p>
<p>Why do you need to use the bluetooth technology ?</p>
<p>Can i control Air Condition (Load of 16A) with this???</p>
<p>Hi,</p><p>the answer is no. The problem is that the relay works with current below to 10A. I think you will be able find in the market something about. In all case I suggest you to view my tutorial about how to control the A/C with Arduino <a href="http://www.instructables.com/id/How-to-control-the-air-conditioner-AC-at-home-with/" rel="nofollow">http://www.instructables.com/id/How-to-control-the...</a> . You will find out a better way to control the A/C. So if you want to use this solution, I mean the Arduino Uno, you can use, but you must keep attention to the relay load. If you want to use a better solution, please visit my other tutorial.</p>
<p>In you ac tutorial you are controlling via remote led but i want type of automation. </p><p>I want to control my hotel with switches and do automation. The scneario would be like this:</p><p>If customer wants ac room , i will put relay 'ON' from my reception control. And the customer further can switch it on off with ac remote.</p><p>If customer wants non-ac room, i will put relay 'OFF' from my reception control. And customer cant switch on the ac with ac remote. because relay wont allow current to pass. I searched net for ip relays and found some 30a relays too. But i dont that would work or not. Also i was looking for some cheaper solution.</p>
<p>Hi,</p><p>I think you will be able to keep the price low. You can use ATMEGA328 (the micro of Arduino, without PCB ) and you can use the Ethernet controller to get connection. So the price would be:</p><p>Atmega 328 plus some items 5-6$ for each room </p><p>Enc28J60 3-4$ for each room</p><p>Relay 10A 1 $ </p><p>One Arduino Mega as the main station 15-20 $</p>
<p>Great tutorial! If you need to buy relay modules, this webstore is selling them for a good price: <a href="http://voltatek.com/en/recherche?tag=relay" rel="nofollow">http://voltatek.com/en/recherche?tag=relay</a></p>
<p>hi there jack, thanks for the great project. am trying to make similar as yours.</p><p>can you please explain am using ethernet shield w5100, do i need to change the library.</p>
<p>Hi,</p><p>thank you for your comment. You have to modify the code to control the lamp from Arduino Uno, using W5100 Ethernet Controller. You can find the correct code from my post http://ismanettoneblog.altervista.org/blog/lezione-14-come-accendere-lampada-remoto-arduino/ . In all case, just a few months a go, there is a new library who let coding with ENC28J60, like using the Ethernet W5100 Controller. If you have any question, please feel free to contact me ! </p>

About This Instructable

50,779views

122favorites

License:

Bio: I'm an Arduino Maker, I like technology, playing tennis
More by jackbell16:How to let comunicate Arduino with KeyPad to DB MySQL. Arduino water system to wet your plant How to make an alarm system with Arduino 
Add instructable to: