mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
35 lines
509 B
Arduino
35 lines
509 B
Arduino
|
//
|
||
|
// FILE: DHT20 _plotter.ino
|
||
|
// AUTHOR: Rob Tillaart
|
||
|
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
|
||
|
//
|
||
|
|
||
|
|
||
|
#include "DHT20.h"
|
||
|
|
||
|
DHT20 DHT(&Wire);
|
||
|
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
DHT.begin();
|
||
|
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 --
|