Electronic – LM75, I2C bad temperature read problem

i2c

I have an LM75 temperature sensor connected to a STM8, 80KHz I2C peripheral. the devices on the bus consist of this sensor and an I2C character LCD (PCF8574T). the LCD works perfectly fine but the temperature sensor, returns a temperature much under the actual value, but if I disconnect it (all pins) and reconnect it, it becomes normal. because all libraries are written by myself, I don't consider them fault proof so I included the logic analyzer outputs. the first write command to chip, is for setting internal register pointer, which is temperature. temperature register is 16 bits, which the MSB is the real part and the LSB is don't care (except the MSbit of LSB). the BAD one which reads 6 degrees which is wrong (I FEEL it!):

LM75 I2C bad temp read

and the GOOD one, same sensor after disconnecting and connecting it again. (the data temperature reads are in HEX, so it's 21 degrees)

LM75 I2C good temp read

what I've done so far ? (without any luck abviously)

  • the logic level and supply voltages, are 5 volts
  • I've tried 2 sensors, same sensor PCB shape, various connection cables. they have on board bypass caps.
  • the wrong temperature goes up when I touch the chip and with the same rate as the working case.
  • I've tried various I2C speed. from 50 to 100 and 200KHz. the clock speed is checked on Logic analyzer.
  • the cable length is under 30cm
  • there are two sda/scl pull-up pairs. one pair on the main PCB (where the MCU is located) and another one on the LCD board. I've tried sensors with and without pullups on board. no luck. the pull-ups are 10K, and are pulled up to 5 volts.

what would be the problem ?

Best Answer

well the problem was fake/defective chips. despite I knew they couldn't be originals, but I thought the whole difference would be a few degrees in temperature that wasn't very bad for my purpose. but I didn't expect a total I2C failure in 5 new chips in a row! if I didn't change one of them with another batch by chance, I wouldn't know and I would have wasted 3 weeks diggin the whole hardware and software from the ground up. lesson learned.