Skip to content

Commit

Permalink
Commit at 29Nov22-1909
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinlyonsrepo committed Nov 29, 2022
1 parent f87b1ea commit 4bde61c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/ahtxx/ahtxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#define AHT10_ADDRESS_0X38 0x38 // I2C address no.1 for AHT10/AHT15/AHT20, adres pin connect to GND
#define AHT10_ADDRESS_0X39 0x39 // I2C address no.2 for AHT10 only, adres pin connect to Vcc
#define AHT10_MY_I2C_DELAY 50 // Timeout for I2C comms, mS,
#define AHT10_MY_I2C_DELAY 50000 // Timeout for I2C comms, uS,

#define AHT10_INIT_CMD 0xE1 // init command for AHT10/AHT15
#define AHT20_INIT_CMD 0xBE // init command for AHT20
Expand Down
14 changes: 7 additions & 7 deletions src/ahtxx/ahtxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ uint8_t LIB_AHTXX::AHT10_readRawData() {
bufTX[1] = AHT10_DATA_MEASURMENT_CMD;
bufTX[2] = AHT10_DATA_NOP;
// Send measurement command
returnValue = i2c_write_blocking(i2c, _address, bufTX, 3 ,false);
returnValue = i2c_write_timeout_us(i2c, _address, bufTX, 3 ,false, AHT10_MY_I2C_DELAY );
if (returnValue < 1 )
return AHT10_ERROR; //error handler, collision on I2C bus

Expand All @@ -66,7 +66,7 @@ uint8_t LIB_AHTXX::AHT10_readRawData() {
busy_wait_ms(AHT10_MEASURMENT_DELAY); // measurement delay

// Read 6-bytes from sensor
returnValue = i2c_read_blocking(i2c, _address, _rawDataBuffer, 6 ,false );
returnValue = i2c_read_timeout_us(i2c, _address, _rawDataBuffer, 6 ,false, AHT10_MY_I2C_DELAY );
if (returnValue < 1) {
_rawDataBuffer[0] = AHT10_ERROR;
return AHT10_ERROR;
Expand Down Expand Up @@ -140,7 +140,7 @@ bool LIB_AHTXX::AHT10_softReset(void) {
uint8_t bufTX[1];
bufTX[0]= AHT10_SOFT_RESET_CMD;

returnValue = i2c_write_blocking(i2c, _address, bufTX, 1 ,false );
returnValue = i2c_write_timeout_us(i2c, _address, bufTX, 1 ,false , AHT10_MY_I2C_DELAY );
if (returnValue < 1)
return false;

Expand All @@ -160,7 +160,7 @@ bool LIB_AHTXX::AHT10_setNormalMode(void) {
bufTX[1] = AHT10_DATA_NOP;
bufTX[2] = AHT10_DATA_NOP;

returnValue = i2c_write_blocking(i2c, _address, bufTX, 3 ,false );
returnValue = i2c_write_timeout_us(i2c, _address, bufTX, 3 ,false , AHT10_MY_I2C_DELAY );
if (returnValue < 1)
return false; //safety check, make sure transmission complete

Expand All @@ -181,7 +181,7 @@ bool LIB_AHTXX::AHT10_setCycleMode(void) {
bufTX[0] = AHT20_INIT_CMD;
bufTX[1] = AHT10_INIT_CYCLE_MODE | AHT10_INIT_CAL_ENABLE;
bufTX[2] = AHT10_DATA_NOP;
returnValue = i2c_write_blocking(i2c, _address, bufTX, 3 ,false );
returnValue = i2c_write_timeout_us(i2c, _address, bufTX, 3 ,false, AHT10_MY_I2C_DELAY );

if (returnValue < 1)
return false; //safety check, make sure transmission complete
Expand All @@ -196,7 +196,7 @@ bool LIB_AHTXX::AHT10_setCycleMode(void) {

uint8_t LIB_AHTXX::AHT10_readStatusByte() {

returnValue = i2c_read_blocking(i2c, _address, _rawDataBuffer, 1 ,false);
returnValue = i2c_read_timeout_us(i2c, _address, _rawDataBuffer, 1 ,false, AHT10_MY_I2C_DELAY );

if (returnValue < 1) {
_rawDataBuffer[0] = AHT10_ERROR;
Expand Down Expand Up @@ -244,7 +244,7 @@ bool LIB_AHTXX::AHT10_enableFactoryCalCoeff() {
bufTX[1] = AHT10_INIT_CAL_ENABLE;
bufTX[2] = AHT10_DATA_NOP;

returnValue = i2c_write_blocking(i2c, _address, bufTX, 3 ,false );
returnValue = i2c_write_timeout_us(i2c, _address, bufTX, 3 ,false, AHT10_MY_I2C_DELAY );

if (returnValue < 1)
{
Expand Down

0 comments on commit 4bde61c

Please sign in to comment.