dimanche 24 avril 2011

Arduino simple home automation: webserver, sensors and emailing alert with livebox orange

In this project, we will connect to the Internet with the Arduino and an ethernet shield to perform data acquisition, LED process control and an email alert.

See video below: 

What this program do:
It creates a web server with Ethernet shield (e.g. DFRDruino) + Arduino (e.g. Duemilanove).

It generates an HTML page for the client that connects to my server (either locally or remotely) that displays:
- Two temperature values ​​from two sensors Dallas One Wire 1820
- Switch ON or OFF a red LED as a function of the input sent by the client.
- Measure the brightness value with a LDR CdS photocell.
- Checks that the values ​​of temperatures are still between a maximum and minimum, if not, it connects to the SMTP internet service provider to send an email alert.

In addition, you can easily add control more LED by extending the LED array in the sketch.

What do you need:

  1 x LED for Visual Feedback
  2 x Dallas Temperature sensors DB1820
1 x Arduino (e.g. Duemilanove)
1 x compatible Ethernet shield for Arduino (official that have Wiznet5100 or DFRDRuino works fine for me, don’t try with the ENC28J60 Ethernet Shield because the Library is a bit hard to handle at the moment)
1x Breadboard
  + various Resistors etc.

How to set-up:

1 - Since we are using a livebox mini from Orange as a router, all the devices that are connected to this LIVEBOX must have IP addresses starting from Therefore, you’ll have to arbitrary allocates addresses for MAC and IP of your shield:
byte mac[] = {0x48,0xC2,0xA1,0xF3,0x8D,0xB7};
byte ip[] = { 192,168,1, 21 };
2 - Connect your shield to the Livebox either by a RJ45 on the wall or directly on the livebox.
3 - Send the arduino sketch to the arduino shield via the IDE software.
4 – Testing your server: enter in the address bar of your favourite browser and hopefully it will give you the below screen:

Refreshing the HTML page will update all the values: light level, Temperature internal and external.
You can now check the input to switch ON the red led and click on send to validate the form. 

5 - Unfortunately, this HTML page is reachable only from your local network but not on the word wide web network. Moreover, since we are using a livebox mini from Orange as our router, its public IP address is dynamic i.e. it changes each time you perform a new connection to the Internet. Hence, you’ll have to do two more steps:
-          Creates an account with e.g. dyndns.org that gives you a mean to have a “fixed” IP address
-           Create a port forwarding on your router to reach your server from everywhere on internet (including Iphone…, every equipment that have an internet connection)
5-1  Enter your livebox management software:

5-2  Click on the configuration page of your router and check out your public IP address (beware that it changes every time you connect to the internet).
Connect to http://www.dyndns.com/services/dns/dyndns/ to create a free account (it’s sufficient for the features that you’ll be using)

You’ll have to enter a hostname for your Livebox, e.g. toto.dyndns.org and also your current IP address (found on 5-2).

5-3 Click on the NAT/PAT” menu to do a “Port Forwarding” from your internal port to the external port: e.g. internal port : DFDruino a.k.a ‘’ port 80 => external port : Web Server public IP port 8080 
Subsequently, the data flow on your router’s IP address on port 80 will be forwarding to This also works in the reverse way.

5-4  More interestingly, we can also add a dyndns rule by clicking on DynDNS menu:

- Choose dyndns on the Service menu
- Enter the dyndns hostname e.g. toto.dyndns.org in the “nom de domaine” field
- Enter the login and password that you have entered on dyndns.org
Once “Enregistrer” is entered the Statut field must indicate a date…

6 -  Entering toto.dyndns.org:8080 must gives you the same screen as the #4 step.

Good luck...

You may want also to check these interesting links: 
- http://www.mon-club-elec.fr/pmwiki_mon_club_elec/pmwiki.php?n=MAIN.ArduinoEthernetServeurControleLEDx7 
- http://www.apress.com/9781430232407 
 - http://www.jlectronique.org/jlectronique/Ethernet_Shield.htm

Aucun commentaire:

Enregistrer un commentaire