Update AHT10.h

This commit is contained in:
enjoyneering 2020-03-20 18:49:07 -04:00 committed by GitHub
parent 0461e8acf2
commit 66f8802f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,12 +51,13 @@
#define AHT10_ADDRESS_0X38 0x38 //chip I2C address 1, address pin connected to GND
#define AHT10_ADDRESS_0X39 0x39 //chip I2C address 2, address pin connected to Vcc
#define AHT10_ADDRESS_0X38 0x38 //chip I2C address no.1 for AHT10/AHT15/AHT20, address pin connected to GND
#define AHT10_ADDRESS_0X39 0x39 //chip I2C address no.2 for AHT10 only, address pin connected to Vcc
#define AHT10_INIT_CMD 0xE1 //initialization command
#define AHT10_INIT_CMD 0xE1 //initialization command for AHT10/AHT15
#define AHT20_INIT_CMD 0xBE //initialization command for AHT20
#define AHT10_START_MEASURMENT_CMD 0xAC //start measurment command
#define AHT10_NORMAL_CMD 0xA8 //normal cycle mode command, no info in datasheet!!!
#define AHT10_SOFT_RESET_CMD 0xBA //soft reset command
#define AHT10_INIT_NORMAL_MODE 0x00 //enable normal mode
@ -65,20 +66,34 @@
#define AHT10_INIT_CAL_ENABLE 0x08 //load factory calibration coeff
#define AHT10_MEASURMENT_DELAY 80 //in milliseconds
#define AHT10_COMMAND_DELAY 35 //in milliseconds
#define AHT10_SOFT_RESET_DELAY 25 //in milliseconds
#define AHT10_DATA_MEASURMENT_CMD 0x33 //no info in datasheet!!! my guess it is DAC resolution, saw someone send 0x00 instead
#define AHT10_DATA_NOP 0x00 //no info in datasheet!!!
#define AHT10_MEASURMENT_DELAY 80 //at least 75 milliseconds
#define AHT10_POWER_ON_DELAY 40 //at least 20..40 milliseconds
#define AHT10_CMD_DELAY 350 //at least 300 milliseconds, no info in datasheet!!!
#define AHT10_SOFT_RESET_DELAY 20 //less than 20 milliseconds
#define AHT10_FORCE_READ_DATA true //force to read data
#define AHT10_USE_READ_DATA false //force to use data from previous read
#define AHT10_ERROR 0xFF //returns 255, if communication error is occurred
typedef enum : uint8_t
{
AHT10_SENSOR = 0x00,
AHT15_SENSOR = 0x01,
AHT20_SENSOR = 0x02
}
ASAIR_I2C_SENSOR;
class AHT10
{
public:
AHT10(uint8_t address = AHT10_ADDRESS_0X38);
AHT10(uint8_t address = AHT10_ADDRESS_0X38, ASAIR_I2C_SENSOR = AHT10_SENSOR);
#if defined(ESP8266)
bool begin(uint8_t sda = SDA, uint8_t scl = SCL);
@ -93,8 +108,9 @@ class AHT10
bool setCycleMode();
private:
uint8_t _address;
uint8_t _rawDataBuffer[6] = {AHT10_ERROR, 0, 0, 0, 0, 0};
uint8_t _address;
ASAIR_I2C_SENSOR _sensorName;
uint8_t _rawDataBuffer[6] = {AHT10_ERROR, 0, 0, 0, 0, 0};
uint8_t readStatusByte();
uint8_t getCalibrationBit(bool readI2C = AHT10_FORCE_READ_DATA);