diff --git a/README.md b/README.md index dc89ff9..7328f88 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ Supports sensors features: The Sensor uses I2C for communication's. Data is outputted (eg to a PC) via a USB. Can be set up for any I2C interface and speed. By default I2C0, GPIO16(SDATA) and GPIO17(SCLK) & 100kHz. +If you want to use the other I2C port (I2C1) in addition to changing in the main.ccp, +The user must change it in library header as well, could not find a way around this. + +* i2c_inst_t *i2c = i2c0 to i2c_inst_t *i2c = i2c1 + **Files** diff --git a/include/ahtxx/ahtxx.hpp b/include/ahtxx/ahtxx.hpp index 4862748..0439e8d 100644 --- a/include/ahtxx/ahtxx.hpp +++ b/include/ahtxx/ahtxx.hpp @@ -57,6 +57,7 @@ class LIB_AHTXX ASAIR_I2C_SENSOR_e _sensorName; uint8_t _rawDataBuffer[6] = {AHT10_ERROR, 0, 0, 0, 0, 0}; int16_t returnValue = 0; + bool isConnected = false; public: // Constructor @@ -76,6 +77,9 @@ class LIB_AHTXX uint8_t AHT10_getCalibrationBit(bool); bool AHT10_enableFactoryCalCoeff(); uint8_t AHT10_getBusyBit(bool); + + void AHT10_SetIsConnected(bool); + bool AHT10_GetIsConnected(void); }; #endif diff --git a/src/ahtxx/ahtxx.cpp b/src/ahtxx/ahtxx.cpp index 858f1b5..a3a47de 100644 --- a/src/ahtxx/ahtxx.cpp +++ b/src/ahtxx/ahtxx.cpp @@ -42,7 +42,11 @@ bool LIB_AHTXX::AHT10_begin() { busy_wait_ms(AHT10_POWER_ON_DELAY); //wait for sensor to initialize AHT10_setNormalMode(); //one measurement+sleep mode - return AHT10_enableFactoryCalCoeff(); //load factory calibration coeff + if (AHT10_enableFactoryCalCoeff()) //load factory calibration coeff + isConnected = true; + else + isConnected = false; + return isConnected; } @@ -289,3 +293,13 @@ void LIB_AHTXX::AHT10_DeInit(i2c_inst_t* i2c_type) i2c_inst_t *i2c = i2c_type; i2c_deinit(i2c); } + +void LIB_AHTXX::AHT10_SetIsConnected(bool connected) +{ + isConnected = connected; +} + +bool LIB_AHTXX::AHT10_GetIsConnected(void) +{ + return isConnected; +} \ No newline at end of file