mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
43 lines
830 B
Arduino
43 lines
830 B
Arduino
|
//
|
||
|
// FILE: AM2315C_plotter.ino
|
||
|
// AUTHOR: Rob Tillaart
|
||
|
// PURPOSE: Demo for AM2315C I2C humidity & temperature sensor
|
||
|
//
|
||
|
|
||
|
// Always check datasheet
|
||
|
//
|
||
|
// +-----------------+
|
||
|
// RED -------- | VDD |
|
||
|
// YELLOW -------- | SDA AM2315C |
|
||
|
// BLACK -------- | GND |
|
||
|
// WHITE -------- | SCL |
|
||
|
// +-----------------+
|
||
|
|
||
|
#include "AM2315C.h"
|
||
|
|
||
|
AM2315C DHT(&Wire);
|
||
|
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
DHT.begin(); // ESP32 default pins 21 22
|
||
|
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 --
|