domenica 24 marzo 2013

How to remotely measure a temperature 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 http://techrm.blogspot.it/2012/12/how-to-interface-arduino-mega-2560-to.html
In this example I use ArduinoIDE version 1.0.3.
Follow the instructions about the setting of the WiShield library (you can load it from https://github.com/rickit69/techrm/tree/master/WiShield_Arduino_IDE_1.0.3). This library is modified to properly work with Arduino Mega 2560 board AND ArduinoIDE version 1.0.3.

Now you need a DS18S20 digital thermometer (http://www.maximintegrated.com/datasheet/index.mvp/id/2815) and a 4.7 kΩ resistor. Now connect them to the Arduino board as shown in the picture:























Now you need to download two applications and a library from https://github.com/rickit69/techrm:
1) test_wifi_temperature, a simple sketch for measure temperature remotely
2) test_arduino_temp_wifi, a simple php application to use with test_wifi_temperature sketch
3) OneWire, more informations at http://playground.arduino.cc/Learning/OneWire

Place the OneWire folder into your Arduino Library. Here are the default library folder locations:
On  Mac:: In (home directory)/Documents/Arduino/libraries
On  Windows:: My Documents -> Arduino -> libraries
On  Linux:: (home directory)/sketchbook/libraries

Put the folder test_arduino_temp_wifi in the documents folder of your  Apache server (for example, in my Fedora Linux it is /var/www/html/). Put the test_wifi_temperature folder in the sketchbook of your Arduino IDE.

In the test_wifi_temperature.ino 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_temp_wifi and, in the test.php and test_controller.php files, modify the ip address (in the example it is 192.168.0.3) according to the ip address in the test_wifi_temperature.ino.

Open a browser and go to the URL http://localhost/test_arduino_temp_wifi/test.php.

You'll see a webpage with a form and one button. The button is to send a request to Arduino which will reply with a xml file containing the temperature value. The php page will display this value. You can see a screenshot below: