Freetronics Temperature and Humidity Sensor (DHT22)

The Sensor

Today I plugged in my new DHT22 temperature and Humidity sensor (buy here).

dht22-sensor

    Features:

  • -4°C to +125°C temperature range with +/-0.5°C accuracy
  • 0-100% relative humidity with 2-5% accuracy
  • 0.5Hz sample rate (one sample every 2 seconds)
  • 3 to 5V operation
  • Power consumption just 4.3mA during reads, even less when idle
  • Blue power LED
  • Dimensions: 31(W) x 23(H) x 4(D)mm

The Wiring

  • VIN: Connect to 5V on your microcontroller.
  • DATA: Connect to a digital I/O line on your microcontroller (e.g Pin 13).
  • GND: Connect to GND (0V) on your microcontroller.

The Code

    >#include
    #include

    #define DHTPIN 13
    #define DHTTYPE DHT22

    DHT dht(DHTPIN, DHTTYPE);

    void setup()
    {
    Serial.begin(115200);
    dht.begin();
    }

    void loop()
    {
    float h = dht.readHumidity();
    float t = dht.readTemperature();

    if (isnan(t) || isnan(h))
    {
    Serial.println("Error reading DHT!");
    }
    else
    {
    Serial.print("Humidity: ");
    Serial.println(h);
    Serial.print("Temp: ");
    Serial.println(t);
    }
    delay(2000);
    }

The Results

Values before and after breathing into the sensor.

    dht22_values

Troubleshooting

I was saving the DHT driver files (DHT.h) to “C:\Program Files (x86)\Arduino\libraries\DHT” and not “%UserProfile%\My Documents\Arduino\libraries”. This is common knowledge but no one says this here, here or here.

Weather Station Project Idea (Ardrino)

So here is the idea, I have heap of sensors from ebay that I have working individually (temp, Humidity, pressure etc) so why not build a weather station.

The most expensive/time consuming part would be building the mechanical stuff to detect the wind/rain (pivot bucket with magnetic sensor) and a solar panel/wifi module. Technically this should not be too hard. A 3D Printer would be handy.

ArdrinoWeatherStationProject

The 555 Timer will trigger update events and the 4 bit timer is really there to help switch open circuits to reuse the limited analogue pins on the Ardrino, EEPROM will save data if the internet is offline. I plan on open sourcing all code and designs.