Recently, I bought cheap infrared temperature sensor, GY-906 from aliexpress, only about $5 including shipping fee.
Adafruit MLX90614 library can be used for this module.
https://github.com/adafruit/Adafruit-MLX90614-Library
Communication via I2C and address is 0x5A. I thought using device is simple as other sensor device; but didn’t work as expected, returning fixed value, 1037.55.
After searching through forum, found out that changing I2C frequency to 50000 makes this thing work.
I can set frequency at Wire.begin if this is only device I’m using, but once I try to use OLED to show readout, OLED works but sensor stops working again.
Finally, I was able to make both OLED and sensor to work by adding setClock instruction to dynamically adjust I2C frequency in Adafruit_MLX90614.cpp source code in Adafruit library.
Adjust to 50000 before transmitting data to sensor, then set back to 100000 before exiting.
uint16_t Adafruit_MLX90614::read16(uint8_t a) {
uint16_t ret;
Wire.setClock(50000);
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.endTransmission(false); // end transmission
Wire.requestFrom(_addr, (size_t)3); // send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
Wire.setClock(100000);
return ret;
}
This post is also available in: Japanese