2022-10-07 05:41:02 -04:00
|
|
|
//
|
|
|
|
// FILE: CHT8305_minimal.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: Demo for CHT8305 I2C humidity & temperature sensor
|
|
|
|
//
|
|
|
|
|
|
|
|
// Always check datasheet - front view
|
|
|
|
//
|
|
|
|
// +---------------+
|
|
|
|
// VCC ----| VCC |
|
2022-10-16 05:14:15 -04:00
|
|
|
// SDA ----| SDA CHT8305 | CHECK DATASHEET.
|
2022-10-07 05:41:02 -04:00
|
|
|
// GND ----| GND |
|
|
|
|
// SCL ----| SCL |
|
|
|
|
// ? ----| AD0 | ? depends on address to select
|
|
|
|
// | |
|
|
|
|
// IRQ ----| ALERT | only if enabled.
|
|
|
|
// +---------------+
|
2022-10-13 10:26:41 -04:00
|
|
|
//
|
|
|
|
// check datasheet
|
|
|
|
// VCC RED
|
|
|
|
// GND BLACK
|
|
|
|
// SDA YELLOW
|
|
|
|
// SCL WHITE
|
2022-10-07 05:41:02 -04:00
|
|
|
|
2022-10-16 05:14:15 -04:00
|
|
|
|
2022-10-07 05:41:02 -04:00
|
|
|
#include "CHT8305.h"
|
|
|
|
|
|
|
|
CHT8305 CHT;
|
|
|
|
|
2022-10-09 10:31:16 -04:00
|
|
|
|
2022-10-07 05:41:02 -04:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
2022-10-16 05:14:15 -04:00
|
|
|
CHT.begin(0x40); // CHT8305_DEFAULT_ADDRESS = 0x40
|
2022-10-09 14:22:05 -04:00
|
|
|
Wire.setClock(400000);
|
2022-10-07 05:41:02 -04:00
|
|
|
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
if (millis() - CHT.lastRead() >= 1000)
|
|
|
|
{
|
|
|
|
// READ DATA
|
2022-10-09 14:22:05 -04:00
|
|
|
CHT.read();
|
2022-10-07 05:41:02 -04:00
|
|
|
|
2022-10-09 14:22:05 -04:00
|
|
|
Serial.print(millis());
|
|
|
|
Serial.print('\t');
|
|
|
|
Serial.print(CHT.getHumidity());
|
|
|
|
Serial.print('\t');
|
|
|
|
Serial.println(CHT.getTemperature());
|
2022-10-07 05:41:02 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-09 10:31:16 -04:00
|
|
|
// -- END OF FILE --
|