2020-11-27 05:10:47 -05:00
|
|
|
//
|
|
|
|
// FILE: DHT12 _plotter.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: Demo for DHT12 I2C humidity & temperature sensor
|
|
|
|
//
|
2021-10-25 11:35:53 -04:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "DHT12.h"
|
2020-11-27 05:10:47 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
DHT12 DHT(&Wire);
|
2020-11-27 05:10:47 -05:00
|
|
|
|
2021-10-25 11:35:53 -04:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
DHT.begin();
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println("Humidity, Temperature");
|
|
|
|
}
|
|
|
|
|
2021-10-25 11:35:53 -04:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
void loop()
|
|
|
|
{
|
2021-10-25 11:35:53 -04:00
|
|
|
if (millis() - DHT.lastRead() >= 1000)
|
|
|
|
{
|
|
|
|
// note no error checking
|
|
|
|
DHT.read();
|
|
|
|
Serial.print(DHT.getHumidity(), 1);
|
|
|
|
Serial.print(", ");
|
|
|
|
Serial.println(DHT.getTemperature(), 1);
|
|
|
|
}
|
2020-11-27 05:10:47 -05:00
|
|
|
}
|
|
|
|
|
2021-12-16 09:58:14 -05:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-16 09:58:14 -05:00
|
|
|
|