36 lines
510 B
Arduino
Raw Normal View History

2020-11-27 11:10:47 +01:00
//
// FILE: DHT12 _plotter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for DHT12 I2C humidity & temperature sensor
//
2021-10-25 17:35:53 +02:00
2020-11-27 11:10:47 +01:00
2021-01-29 12:31:58 +01:00
#include "DHT12.h"
2020-11-27 11:10:47 +01:00
2021-01-29 12:31:58 +01:00
DHT12 DHT(&Wire);
2020-11-27 11:10:47 +01:00
2021-10-25 17:35:53 +02:00
2020-11-27 11:10:47 +01:00
void setup()
{
DHT.begin();
Serial.begin(115200);
Serial.println("Humidity, Temperature");
}
2021-10-25 17:35:53 +02:00
2020-11-27 11:10:47 +01:00
void loop()
{
2021-10-25 17:35:53 +02: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 11:10:47 +01:00
}
2021-12-16 15:58:14 +01:00
2020-11-27 11:10:47 +01:00
// -- END OF FILE --
2021-12-16 15:58:14 +01:00