Monday, March 23, 2015

First Experiment - Digital Temperature and Humidity Sensor(DHT22) + Wifi Yun Shield(Dragino)

Preparation:



  1. DHT22 Digital Temperature and Humidity Sensor: I bought this one from Amazon.


  2. Arduino with bread board: This one on Amazon seems to be reasonable.

  3. Arduino IDE: You can follow this instruction to set up.
  4. I wired the DHT22 sensor to Yun Shield as shown below. If you are not using Yun Shield, then just wire it like this tutorial(basically they are the same wiring).




Coding:



Test Sensor:
  1. Download Arduino sketch for DHT11DHT22
  2. Load it to Arduino via Wifi(see how in my previous post). 
  3. Now we need to change all serial API calls to console API calls. Since we don't have any USB connect to the Arduino+Yun Shield, Console.print will allow us to see all string output via Wifi instead of serial port.
    ex.
    #include <Bridge.h>
    Bridge.begin(); // Make contact with the linux processor from UNO. This must be added before the Console API
    Serial.begin(9600); => Change to Console.begin();
    Serial.println("xxxxx"); => Change to Console.println("xxxxx"); 
  4. Compile and run again to make sure we can see logs from the serial monitor console.
Test Web Server:
Now we need to create a web HTTP server so we can view Temperature and Humidity changes via a browser.
  1. Get an USB drive and create a directory structure under the root. /arduino/www
  2. Create an index.html file and put under www folder. It's content can be as simple as <h1>Hello!</h1>
  3. Plug in the USB drive to the Yun Shield. Now open a browser and enter your Arduino's IP address.ex. http://192.168.1.99/sd/ => This will show /arduino/www/index.html in the USB drive.
  4. If it does not work, ssh to your Arduino and see if you can find the folder and the html file as below.




Reference:



  1. https://plot.ly/arduino/dht22-temperature-tutorial/
  2. http://www.open-electronics.org/interact-and-remotely-control-arduino-yun-with-ajax/

No comments:

Post a Comment