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

57 lines
1.0 KiB
Arduino
Raw Normal View History

//
// FILE: dht12_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DHT library test sketch for DHT12 && Arduino
2021-01-29 06:31:58 -05:00
// URL: https://github.com/RobTillaart/DHTlib
2021-12-16 10:44:08 -05:00
#include <dht.h>
dht DHT;
2021-12-16 10:44:08 -05:00
#define DHT12_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)");
}
2021-12-16 10:44:08 -05:00
void loop()
{
// READ DATA
Serial.print("DHT12, \t");
int chk = DHT.read12(DHT12_PIN);
switch (chk)
{
case DHTLIB_OK:
2021-12-16 10:44:08 -05:00
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
2021-12-16 10:44:08 -05:00
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
2021-12-16 10:44:08 -05:00
Serial.print("Time out error,\t");
break;
default:
2021-12-16 10:44:08 -05:00
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
delay(2000);
}
2021-12-16 10:44:08 -05:00
// -- END OF FILE --