GY-63_MS5611/libraries/DHTlib/examples/dht22_test/dht22_test.ino

63 lines
1.2 KiB
Arduino
Raw Normal View History

2013-08-28 07:57:45 -04:00
//
// FILE: dht22_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
2013-08-28 07:57:45 -04:00
// PURPOSE: DHT library test sketch for DHT22 && Arduino
// URL:
//
// Released to the public domain
//
#include <dht.h>
dht DHT;
#define DHT22_PIN 5
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)");
2013-08-28 07:57:45 -04:00
}
void loop()
{
// READ DATA
Serial.print("DHT22, \t");
uint32_t start = micros();
int chk = DHT.read22(DHT22_PIN);
uint32_t stop = micros();
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.print(",\t");
Serial.print(stop - start);
Serial.println();
delay(2000);
2013-08-28 07:57:45 -04:00
}
//
// END OF FILE
//