mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
53 lines
965 B
C++
53 lines
965 B
C++
//
|
|
// FILE: CHT8305_minimal.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// PURPOSE: Demo for CHT8305 I2C humidity & temperature sensor
|
|
//
|
|
|
|
// Always check datasheet - front view
|
|
//
|
|
// +---------------+
|
|
// VCC ----| VCC |
|
|
// SDA ----| SDA CHT8305 | TODO CHECK DATASHEET.
|
|
// GND ----| GND |
|
|
// SCL ----| SCL |
|
|
// ? ----| AD0 | ? depends on address to select
|
|
// | |
|
|
// IRQ ----| ALERT | only if enabled.
|
|
// +---------------+
|
|
|
|
|
|
#include "CHT8305.h"
|
|
|
|
CHT8305 CHT;
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
|
|
CHT.begin(0x40); // default address
|
|
Wire.setClock(400000);
|
|
|
|
delay(1000);
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
if (millis() - CHT.lastRead() >= 1000)
|
|
{
|
|
// READ DATA
|
|
CHT.read();
|
|
|
|
Serial.print(millis());
|
|
Serial.print('\t');
|
|
Serial.print(CHT.getHumidity());
|
|
Serial.print('\t');
|
|
Serial.println(CHT.getTemperature());
|
|
}
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|