#ifndef __AHT2x_H #define __AHT2x_H #include #define AHT_I2C_ADDR 0x38 class AHT2x { public: AHT2x(TwoWire &i2c); bool setup(uint8_t address = AHT_I2C_ADDR, bool crc = false); bool scan(); bool isReady(); bool isCalibrated(); void reset(); bool readSensor(unsigned long tick); inline int16_t getHumidity() const { return m_nRH; } inline int16_t getTemperature() const { return m_nTemp; } inline void setScanFlag(bool bScan) { m_bScan = bScan; } inline bool sensor() { return m_bSensor; } private: TwoWire &_i2c; uint8_t m_nAddress; bool _active_crc; uint8_t _buf[7]; int16_t m_nRH, m_nTemp; int16_t humid[4], temp[4]; uint8_t status(); void calibrate(); bool measure(); uint8_t crc8(); void requestMeasurement(unsigned long tick); bool bRequested; bool m_bSensor; bool m_bScan; unsigned long tickRequested; uint8_t m_nErrorCount; }; extern class AHT2x aht25, aht10_0x39; #endif