GY-63_MS5611/libraries/DHTstable/examples/dht11_test/dht11_test.ino

57 lines
1.0 KiB
Arduino
Raw Normal View History

2015-08-20 17:02:36 -04:00
//
// FILE: dht11_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DHT library test sketch for DHT11 && Arduino
2020-11-27 05:10:47 -05:00
// URL: https://github.com/RobTillaart/DHTstable
2021-12-16 16:03:02 -05:00
2015-08-20 17:02:36 -04:00
2021-01-29 06:31:58 -05:00
2021-05-28 07:22:49 -04:00
#include "DHTStable.h"
2015-08-20 17:02:36 -04:00
2021-05-28 07:22:49 -04:00
DHTStable DHT;
2015-08-20 17:02:36 -04:00
2021-12-16 16:03:02 -05:00
#define DHT11_PIN 5
2015-08-20 17:02:36 -04:00
2021-05-28 07:22:49 -04:00
2015-08-20 17:02:36 -04:00
void setup()
{
Serial.begin(115200);
2021-01-29 06:31:58 -05:00
Serial.println(__FILE__);
2015-08-20 17:02:36 -04:00
Serial.print("LIBRARY VERSION: ");
2021-05-28 07:22:49 -04:00
Serial.println(DHTSTABLE_LIB_VERSION);
2015-08-20 17:02:36 -04:00
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
2021-05-28 07:22:49 -04:00
2015-08-20 17:02:36 -04:00
void loop()
{
// READ DATA
Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
2021-01-29 06:31:58 -05:00
Serial.print("OK,\t");
break;
2015-08-20 17:02:36 -04:00
case DHTLIB_ERROR_CHECKSUM:
2021-01-29 06:31:58 -05:00
Serial.print("Checksum error,\t");
break;
2015-08-20 17:02:36 -04:00
case DHTLIB_ERROR_TIMEOUT:
2021-01-29 06:31:58 -05:00
Serial.print("Time out error,\t");
break;
2015-08-20 17:02:36 -04:00
default:
2021-01-29 06:31:58 -05:00
Serial.print("Unknown error,\t");
break;
2015-08-20 17:02:36 -04:00
}
// DISPLAY DATA
2021-01-29 06:31:58 -05:00
Serial.print(DHT.getHumidity(), 1);
2015-08-20 17:02:36 -04:00
Serial.print(",\t");
2021-01-29 06:31:58 -05:00
Serial.println(DHT.getTemperature(), 1);
2015-08-20 17:02:36 -04:00
delay(2000);
}
2021-01-29 06:31:58 -05:00
2021-12-16 16:03:02 -05:00
2021-05-28 07:22:49 -04:00
// -- END OF FILE --