mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
59 lines
1.0 KiB
C++
59 lines
1.0 KiB
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 | CHECK DATASHEET.
|
|
// GND ----| GND |
|
|
// SCL ----| SCL |
|
|
// ? ----| AD0 | ? depends on address to select
|
|
// | |
|
|
// IRQ ----| ALERT | only if enabled.
|
|
// +---------------+
|
|
//
|
|
// check datasheet
|
|
// VCC RED
|
|
// GND BLACK
|
|
// SDA YELLOW
|
|
// SCL WHITE
|
|
|
|
|
|
#include "CHT8305.h"
|
|
|
|
CHT8305 CHT;
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
|
|
CHT.begin(0x40); // CHT8305_DEFAULT_ADDRESS = 0x40
|
|
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 --
|