Browse Source

Fix AM2302 sensor

rfm69
Xose Pérez 6 years ago
parent
commit
427aebe8a7
2 changed files with 4 additions and 1 deletions
  1. +1
    -0
      code/espurna/config/prototypes.h
  2. +3
    -1
      code/espurna/sensors/AM2320Sensor.h

+ 1
- 0
code/espurna/config/prototypes.h View File

@ -77,6 +77,7 @@ bool i2cGetLock(unsigned char address);
bool i2cReleaseLock(unsigned char address);
unsigned char i2cFindAndLock(size_t size, unsigned char * addresses);
void i2c_wakeup(uint8_t address);
uint8_t i2c_write_buffer(uint8_t address, uint8_t * buffer, size_t len);
uint8_t i2c_write_uint8(uint8_t address, uint8_t value);
uint8_t i2c_write_uint8(uint8_t address, uint8_t reg, uint8_t value);


+ 3
- 1
code/espurna/sensors/AM2320Sensor.h View File

@ -120,7 +120,9 @@ class AM2320Sensor : public I2CSensor {
*/
void _read() {
i2c_wakeup();
// waiting time of at least 800 μs, the maximum 3000 μs
delayMicroseconds(800); // just to be on safe side
@ -128,7 +130,7 @@ class AM2320Sensor : public I2CSensor {
// 4 = number of bytes to read
if (i2c_write_uint8(_address, AM2320_I2C_READ_REGISTER_DATA, 0x00, 4) != I2C_TRANS_SUCCESS) {
_error = SENSOR_ERROR_TIMEOUT;
return false;
return;
}
unsigned char _buffer[8];


Loading…
Cancel
Save