Monday, April 14, 2014

Arduino Weatherstation - Temperature

I ended up purchasing a DHT22/AM2302 sensor, so I quickly put together a rudimentary Arduino sketch to read the temperature and relative humidity and calculate the dew point.

Components

  1. Arduino Duemilanove
  2. Jumper wires (x3)
  3. Breadboard
  4. DHT sensor
The DHT sensor has four pins and its connections are as follows (from left to right):
  1. +5 V --> 5 V on Arduino
  2. Data --> Digital input pin 5
  3. Not used
  4. Ground --> Gnd on Arduino
I used DHTlib to read sensor values. This library makes reading these values trivial. I modified DHTlib, removing the methods for reading from DHT11 and DHT21 sensors. When you only have ~30k bytes of memory, every bit counts!

My sketch was modified from the DHTlib example and can be seen below:

Show Code

Every two seconds, the sensor status, current temperature in Fahrenheit, % relative humidity, and approximate dew point will be printed to the Arduino serial monitor.