Sming - Open Source framework for high efficiency native ESP8266 development

User avatar
By colinmeikle
#48176 Has anyone tried using the MLX90614 IR temp sensor with sming ? The sensor uses SMB protocol which is similar to i2c . From what I can see Ardiuno users have it wring using the i2c Wire interface. However in my setup every second read fails, this is consistent and my workaround is to put in a dummy read however I'd like to understand what the root cause is. Had anyone seen anything similar

here is my read function

//reads 16 bit number from bus + error byte (not used)
uint16_t MLX90614::i2cRead(uint8_t reg){

uint16_t ret;
Wire.beginTransmission(_i2cAddr); // start transmission to device
Wire.write(reg); // sends register address to read from
Wire.endTransmission(false); // end transmission

Wire.requestFrom(_i2cAddr, (uint8_t)3);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA

//error
uint8_t pec = Wire.read();

Wire.endTransmission(true); // end transmission
return ret;
}
User avatar
By hreintke
#48210 I am not very experienced with i2c but..

In other applications/libraries using i2c I do not see the use of

Wire.endTransmission(true); // end transmission

To end a

Wire.requestFrom(_i2cAddr, (uint8_t)3);// send data n-bytes read