DHT22 Temperature/Humidity sensor ladyada DHT22 Library: How to slow it down

by DennyP on Sat May 25, 2013 9:00 am

Hello all,

I'm currently using the library http://learn.adafruit.com/dht for my DHT22 and I'm using a Adrunio Uno.
The sketch is working, providing me with data every 250 milliseconds (according to the code).

However I want to increase this to a second/1000 milliseconds.

How can I do this? I was thinking using a delay code (don't know where to put it), or editing the Dht.h file that came with it.

The code is as follows:
Code: Select all
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)


void setup() {
  Serial.println("LABEL,Time,Temperature (C), Humidity (%)"); 


void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print("DATA,TIME,"); Serial.print(t); Serial.print(","); Serial.println(h);

Posts: 5
Joined: Sat May 18, 2013 5:41 am

Re: DHT22 Temperature/Humidity sensor ladyada DHT22 Library: How to slow it down

by adafruit_support_bill on Sat May 25, 2013 10:14 am

The simplest way is to add a "delay(750);" anywhere in the loop.
User avatar
Posts: 25398
Joined: Sat Feb 07, 2009 9:11 am