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)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(38400);
Serial.println("LABEL,Time,Temperature (C), Humidity (%)");
dht.begin();
}
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);
}
}
Dennis