giovedì 10 gennaio 2013

How to remotely control a led using Arduino and WiFi

First you need an Arduino Mega 2560 board and a Weburban WiFi board (this board uses standard connectors over SPI to an Arduino compatible Microchip 802.11b/g/n MRF24WB0MA).
Connect them as showed in
In this example I use ArduinoIDE version 0021.
Follow the instructions about the setting of the WiShield library.

Now  connect a 470 ohm resistor and a led in series between pin 12 and pin gnd of the Arduino, as shown below:

  This picture shows the final result:


Now you need to download two applications from
1) test_arduino, a simple php application
2) test_my_server, a simple sketch.

Put the folder test_arduino in the documents folder of your  Apache server (for Linux it could be /var/www/html/). Put the test_my_server folder in the sketchbook of your Arduino IDE.

In the test_my_server.pde file modify the wireless parameters (ip address, subnet mask, gateway, SSID, security type,  WPA/WPA2 passphrase or WEP keys) according to your wireless network parameters.

Compile the sketch and load to the Arduino.

Now go in the folder test_arduino and, in the test.php and test_controller.php files, modify the ip address (in the example it is according to the ip address in the test_my_server.pde.

Open a browser and go to the URL http://localhost/test_arduino/test.php.
You'll  see a web page with a form with 2 buttons. One button is to turn on the led, the other one is to turn it off.

The sketch test_my_server receives the commands from the php app test_arduino and then turns on/off the led.

The video below shows you the application running: