2022-01-11 14:48:39 -05:00
|
|
|
//
|
|
|
|
// FILE: DHT20 _plotter.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
|
|
|
|
//
|
|
|
|
|
2022-09-11 05:44:04 -04:00
|
|
|
// Always check datasheet - front view
|
|
|
|
//
|
|
|
|
// +--------------+
|
|
|
|
// VDD ----| 1 |
|
|
|
|
// SDA ----| 2 DHT20 |
|
|
|
|
// GND ----| 3 |
|
|
|
|
// SCL ----| 4 |
|
|
|
|
// +--------------+
|
2022-01-11 14:48:39 -05:00
|
|
|
|
|
|
|
#include "DHT20.h"
|
|
|
|
|
|
|
|
DHT20 DHT(&Wire);
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
2022-09-11 05:44:04 -04:00
|
|
|
DHT.begin(); // ESP32 default pins 21 22
|
2022-01-11 14:48:39 -05:00
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println("Humidity, Temperature");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
if (millis() - DHT.lastRead() >= 1000)
|
|
|
|
{
|
|
|
|
// note no error checking
|
|
|
|
DHT.read();
|
|
|
|
Serial.print(DHT.getHumidity(), 1);
|
|
|
|
Serial.print(", ");
|
|
|
|
Serial.println(DHT.getTemperature(), 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|