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 192.168.1.10. Therefore, you’ll have to arbitrary allocates addresses for MAC and IP of your shield:
e.g.:
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 192.168.1.21 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: http://192.168.1.1/hnm/standard/HNM_Header/html/header_pc.html

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 ‘192.168.1.21’ 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 192.168.1.21:8080. 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

dimanche 17 avril 2011

Arduino Simon Game: Version 3

Initial Release from David M. Auld (19th October 2009) => Version 1 & 2

http://www.dave-auld.net/index.php?option=com_content&view=article&id=96:arduino-project-simon-game&catid=54:arduino-projects&Itemid=107

Added some features by jadiema => Version 3:
  NEW: Added EEPROM storage for high score: level and name
  NEW: Multilangage selection
You'll find the code at: http://code.google.com/p/my-arduino-projects/downloads/detail?name=Arduino_SimonGame_EEPROM_LANGUE_V3_1.pde&can=2&q=#makechanges


 It uses the following Hardware;
  4 x LEDs for Visual Feedback of step
  4 x Pushbuttons for Input of step
  1 x Speaker for Audio Feedback of Step
  1 x LCD for Game Info and Scoring.
  1 x Arduino
  +various Resistors/pots etc.
  Built and tested on Arduino Duemilanove.

My first time-lapse with an arduino and a CANON EOS450D



Last week, I decided to use my photo camera for time-lapse shots, however to do that, I needed a so-called intervalometer. Damned, what is an intervalometer ?
It's a device that times the shots to regular intervals, but those are so expensive, and cost for the CANON EOS 450D around €150, just for a tiny microcontroler and an IR LED.
So I decided to build my own with my favorite open source hardware: arduino.

Here's some example timelapse movies made with several hundred of jpg pictures taken from 4pm to 10pm



Here's my second timelapse movie made with several hundred of jpg pictures taken from 6pm to 9pm.


 Here's my first timelapse movie made with several hundred of jpg pictures taken from 8am to 11am.



The setup in action (a shoot every 30s):


The Arduino code :
http://code.google.com/p/my-arduino-projects/downloads/detail?name=CanonEOS_Sandra_TimeLapse.pde&can=2&q=#makechanges

IR LED with its holder
 

Small breakboard with two buttons (manual or automatic mode), several resistors to manage multiple button choice on analog pin 0, and a voltage divider that holds the IR LED on the image bottom.

Required Parts:
  • 1x Arduino (e.g. Diecimila)
  • 3x 1kohm resistors
  • 1x 4.7kohm resistor
  • 1x IR LED 940nm
  • 2 x push buttons 
  • 1x Arduino AC adapter OR Arduino 9V battery pack
  • 1x box ;-)))


The code is derived from code: 
http://controlyourcamera.blogspot.com/2010/01/infrared-controlled-timelapse.html
Software to mount the images together: Photolapse (freeware): http://home.hccnet.nl/s.vd.palen/index.html

lundi 21 mars 2011

Adding some features to Arduino Beat Bearing tangible sequencer

I built the Peter Bennett sequencer (BeatBearing Tangible Sequencer Rhythm) of MAKE vol#17 and was pleased to add some new features:


   1 - A potentiometer to vary the tempo of the song 
   2 - A push button counter to select the bank samples in your soft synth software (e.g. Ableton live)
   3 - Naming of the samples on top and right of the grid 
   4 - A touch screen DS for recording and playing sequences !














Modified code can be found here (Beat Bearing Plus):
http://code.google.com/p/my-arduino-projects/downloads/list
The zip file include the samples and the ableton file...


Or you can visit the Peter Bennet initial pages: 
pete@petecube.com
BeatBearing:  www.beatbearing.co.uk
------------------------------------
Please refer to the Forum at www.beatbearing.co.uk 

dimanche 20 mars 2011

Sending nunchuk and Wii Motion Plus data from Arduino to LabView

I created a small application with an Arduino which get data from:
1- a Nintendo nunchuck 
2- a Nintendo Wii motion Plus 
and send these data to Labview for plotting

The embedded program in the arduino prints out information from these different sensors.
The LabView program get the data from the serial port and plots the data two three graphs.
 




The codes are available here:
 http://code.google.com/p/my-arduino-projects/downloads/list

 Parts of the code are adapted from the following codes:
 Nunchuck management: http://www.windmeadow.com/node/42
WiiMotionPlus management: http://randomhacksofboredom.blogspot.com/2009/06/wii-motion-plus-arduino-love.html
http://voidbot.net/nunchchuk-and-wii-motion-plus-6-DOF.html


The Labview code was adapted from code found here: http://web.me.com/iklln6/automation/LabVIEW.html

jeudi 10 mars 2011

Arduino & RFID reader, Piezo Sounder Melody Player, Relay activation, and EEPROM Write

A small application with an Arduino or rather a clone called RBBB:
- RFID reader cards (ID12 reader - 125kHz)
- If the RFID card is valid, it plays a melody corresponding to each card, if not, it beeps and lights a red LED,
- Then it activates a relay if the card is valid
- And finally write in the EEPROM memory of the Arduino, the number of times the card was used.
The melodies are played by a piezoelectric buzzer. There are now 5 songs recorded in the Arduino: indiana jones, star wars, mario bros, tetris ...
 




To create this application I've adapted codes that I found here and there, some part of the sketch comes from:
1 - RFID reader Mickael ROBERTS: Beginning Arduino (Apress)
2 - Piezo Sounder Melody Player Mickael ROBERTS: Beginning Arduino (Apress)
3 - management of the EEPROM is inspired by the Arduino page http://www.arduino.cc/en/Reference/EEPROM
You will find the source code here:
http://code.google.com/p/my-arduino-projects/downloads/list




------------------------------------------------------------------------------------------------------------------------------

Une petite application avec un Arduino ou plutôt un clone RBBB  qui:
- lit des cartes RFID (ID12 reader - 125kHz),
- si la carte est valide, joue une mélodie correspondante à chacune des cartes, sinon émet un son et allume une LED rouge,
- puis, actionne un relay si la carte est valide,
- et enfin écrit dans la mémoire morte de l'Arduino, le nombre de fois que la carte a été utilisée. 

Les mélodies sont jouées par un buzzer piezoélectrique.
Il y a pour l'instant 5 mélodies enregistrées dans l'Arduino:
indiana jones, star wars, mario bros, tétris...

Pour créer cette application j'ai
adapté des codes que j'ai trouvés par ci par là, notamment une partie du sketch provient de:
1 - RFID reader de Mickael ROBERTS: Beginning Arduino (APRESS)
2 - Piezo Sounder Melody Player de Mickael ROBERTS: Beginning Arduino (APRESS)
3 - la gestion de l'EEPROM de l'Arduino est inspiré de la page http://www.arduino.cc/en/Reference/EEPROM

Vous trouverez le code source ici:
http://code.google.com/p/my-arduino-projects/downloads/list

jeudi 3 mars 2011

Controlling a fan with an Arduino, a nunchuk, a DS touch screen and a PID

Controlling a fan with an Arduino, a nunchuk, a DS touch screen and a PID:
I created a small application with an Arduino, which calculates and controls (with or without PID) the rotation speed of a fan from three items:
1- a Nintendo nunchuck 
2- a Nintendo DS screen 
3- a Temperature Sensor TMP36

A tilt sensor can switch off the fan if a vibration is detected, a red LED lights up and waits for user intervention.

This application could for example be used to regulate the temperature inside a box.

The fan speed is calculated by interruptions performed by the Arduino and generated through an optocoupler placed against the fan.
Note: the program would work equally well with a Hall effect sensor, but I left solution because my magnet was too strong and blocked my fan;-).

A PID Arduino library can control the rotation speed according to a setting point speed obtained using a correspondance between speed and temperature, vitesse_consigne = f (temperature).



1 - The DS screen is used to:
 - select different speeds by pressing the keys 0-9, minimum = 0 and at maximum = 2100 rpm (with a 9V battery).
 - switch to control or PID control temperature by pressing the C key
 - the E button stops the rotation of the fan



2 - The Nunchuk mode is activated by pressing constantly on Z button, the X acceleration then vary the fan speed, for values ​​ranging from speed 1 to 9 (same speeds as the DS screen).

 In "stand alone" mode, i.e. without RBBB plugged into the USB port of the PC, I placed an RGB LED that displays a color based on the rotational speed of the fan: e.g. red for the first gear and Green for the ninth speed. If the temperatrure is higher than 25°C, the speed is set to its maximum and the Blue led is lighted. 





PART2:
The embedded program in the arduino prints out information from different sensors.
 You can preview an example of what the program prints out, looking at the below field "Raw Output" T = 19.82 | rpm = 840 | (X, Y) = 1006, 1007 | RGBLED = 285, -30, 0 | Acc = 175, 124, 161 | to = 1.1 | joy = 125.128
 I then created a LabView program that formats that comes out the serial port and can either:
 - read this information if "Read" is enabled,
 - or write to the serial port to take control of the fan if "Write" is enabled.



 With the example above:

T = 19.82 | rpm = 840 | (X, Y) = 1006, 1007 | RGBLED = 285, -30, 0 | Acc = 175, 124, 161 | to = 1.1 | joy = 125.128


T: temperature
 rpm: fan speed
 (X, Y) coordinates of the DS screen
 RGBLED: intensity values ​​of the PWM pin for the LED Red, Green and Blue respectively
 acc: acceleration values ​​of the three axes X, Y, Z Nunchuck
 button: button states Z and C respectively Nunchuck (1: pressed, 0: released)
 Joy: values ​​of the two axes X, Y joystick Nunchuck

The codes are available here:
 http://code.google.com/p/my-arduino-projects/downloads/list

 Parts of the code are adapted from the following codes:
 Nunchuck management: http://www.windmeadow.com/node/42
 Touch Screen management: Mick Roberts: Beginning Arduino (from Apress)
 Debounce management: http://www.arduino.cc/en/Tutorial/Debounce

 PID management: http://www.arduino.cc/playground/Code/PIDLibrary
 The Labview code was adapted from code found here: http://web.me.com/iklln6/automation/LabVIEW.html

-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
Régulation d'un ventilateur avec un arduino, un nunchuk, une DS touch screen et un PID:
 
J'ai créé une petite application avec un Arduino qui calcule et régule (avec ou sans PID) la vitesse de rotation d'un ventilateur à partir de trois objets:
1 - un nunchuck de Nintendo ou
2 - un écran de DS de Nintendo ou
3  - un capteur de température TMP36

Un capteur d'inclinaison permet de couper l'alimentation du ventilateur si une inclinaison est détectée, une led rouge s'allume alors et attend l'intervention de l'utilisateur. 
Cette application pourrait par exemple servir à réguler la température dans une enceinte.

La vitesse du ventilateur est calculée grâce à des interruptions interprétées par l'Arduino et générées par l'intermédiaire d'un optocoupleur placé face au ventilateur. Remarque: le programme marcherait tout aussi bien avec un capteur à effet Hall, mais j'ai abandonné cette solution car mon aimant était trop puissant et arrêtait mon ventilateur ;-).
Une librairie PID de l'Arduino permet de réguler la vitesse de rotation du moteur en fonction d'une vitesse de consigne obtenue à l'aide d'une abaque vitesse_consigne = f(température). 



1 - L'écran de DS permet de:
- sélectionner les différentes vitesses de rotation en appuyant sur les touches de 0 à 9, soit de minimum = 0 à maximum = 2100 rpm (avec une pile de 9V).
- passer en mode commande ou régulation PID en température en appuyant sur la touche C
- la touche E arrête la rotation du ventilateur

2 - Le mode Nunchuk s'active en appuyant constamment sur Z, l'accélération X fait alors varier la vitesse du ventilateur, pour des valeurs comprises entre la vitesse 1 à 9.

En mode "stand alone", c'est à dire sans brancher le RBBB sur le port USB du PC, j'ai placé une LED RGB qui affiche une couleur fonction de la vitesse de rotation du ventilateur: e.g. Rouge pour la première vitesse, et Verte pour la neuvième vitesse. Si la température dépasse 25°C, la vitesse du ventilateur est mise à son maximum et la diode bleu s'allume.


Le programme embarqué dans l'arduino sort les informations des différents capteurs.
Vous pouvez avoir un exemple d'aperçu de ce que sort le sketch en regardant le champ "Raw Output":
T=19.82|rpm=840|(X,Y)=1006, 1007|RGBLED=285, -30, 0|acc=175, 124, 161|but=1,1|joy=125,128

2ème partie:
J'ai alors créé un programme LabView qui formate ce qui sort du port série et permet de soit:
- lire ces informations si "Read" est activé,
- soit écrire sur le port série pour prendre la main du ventilateur si "Write" est activé.


Avec l'exemple ci-dessus: 
T=19.82|rpm=840|(X,Y)=1006, 1007|RGBLED=285, -30, 0|acc=175, 124, 161|but=1,1|joy=125,128

T: temperature
rpm: vitesse du ventilateur
(X,Y): coordonnées de l'écran de DS
RGBLED: valeurs d'intensité de la pin PWM pour la led Rouge, Vert, Bleu respectivement
acc: valeurs d'accélération des trois axes X, Y, Z du Nunchuck
but: états du bouton Z et C respectivement du Nunchuck (1: appuyé, 0: relaché)
joy: valeurs des deux axes X, Y du joystick du Nunchuck


Les codes sont disponibles ici:
http://code.google.com/p/my-arduino-projects/downloads/list

Les parties du code sont adaptées des codes suivants:
Gestion du Nunchuck: http://www.windmeadow.com/node/42
Gestion du Touch Screen:  Mickael Roberts: Beginning Arduino (from Apress)
Gestion du debounce:  http://www.arduino.cc/en/Tutorial/Debounce
Gestion du PID: http://www.arduino.cc/playground/Code/PIDLibrary
Le code Labview a été adapté du code trouvé ici: http://web.me.com/iklln6/automation/LabVIEW.html