Description
Hardware:
Board: Custom board
Core Installation/update date: Latest master
IDE: esp-idf with Arduino as component
Description:
I'm having issue with MLX90614 sensor. Using latest core and this Arduino code, it doesn't work anymore. If using previously I2C, before @stickbreaker I2C code merged to master, it all works fine on the very same board. So, the issue is clearly not hardware.
What I meant by "doesn't work" is that the data returned by Wire.read() never be right. Using previous I2C code, it return expected values.
I've tried two libs:
https://github.com/adafruit/Adafruit-MLX90614-Library
https://github.com/sparkfun/SparkFun_MLX90614_Arduino_Library
both not working.
Sketch:
Using examples on both libraries
What I did:
Tried to change clock varying from 10KHz to 100KHz doesn't help (the sensor supports that range). Also changing timeout doesn't help.
Tried to change Adafruit's library to this:
uint16_t ret;
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
uint8_t err = Wire.endTransmission(false); // end transmission
if( err!=7){ // something went wrong
Serial.printf("Error setting register pointer =%d (%s)",Wire.lastError(),Wire.getErrorText(Wire.lastError()));
}
uint8_t cnt = Wire.requestFrom(uint8_t(_addr), (uint8_t)3);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
Serial.printf("\nCnt: %d, ret: 0x%x, pec: 0x%x, reg: 0x%x\n", cnt, ret, pec, a);
return ret;
Always return Cnt: 3, ret: 0x0, pec: 0x0, reg: 0x7
Meaning ret
is always zero.
Please kindly advice. Thanks.