Bug in the internal I2C LM75 code #24263
Replies: 7 comments 8 replies
-
|
The native driver has a pretty simple logic to read the sensor, which looks like it can only produce a 0 if that matches what the sensor returned. Tasmota/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino Lines 70 to 80 in 677eaba The ConvertTemp call is for handling unit C/F, but should not be able to invalidate the input value.
Is your Berry code to read the sensor doing something better? |
Beta Was this translation helpful? Give feedback.
-
|
My conclusion also rests on the 0 (zero). When the sensor produces an error, the returned value is a "missing value", but it is returned as a 0. As example I list some values: In my setup I have a single LM75B chip (at default address 0x48) and I am first calling it by the "native" driver The LM75B chip fails for 6 sec in a row (based on Berry result 'Temp is None'). During the same time period, the native driver produces '0.0' as float. I conclude that the native driver produces a valid zero when the sensor fails, actually giving invalid data! Instead it should produce a missing value! So every time the sensor fails - and this seems to happen surprisingly often - a false and highly misleading value is produced! It is a big No-No, returning as missing-value a value which is well within the range of correct values! Remember, according to the LM75B datasheet https://www.ti.com/product/de-de/LM75B its Temp range is -55...+125 °C. The proper way of handling such a situation would be to call it a 'nan' (Not a Number) value. In Berry code easily done as My Berry code is simple, but it does produce 'nan' values. One catch, though: the Python3 json functions do not recognize 'nan', but they do recognize 'null' (and make a Python 'None' out of it). So I workaround by changing 'nan' to 'null' before I A minor other quibble I have: these sensors come as 'LM75', 'LM75A', and 'LM75B'. The 'D' in LM75AD does not belong there, because it is just a package variant, which has nothing to do with the code. The 'LM75' has 9 Bit resolution, the A and have 11 bit. The B is the latest variant (with some better stability specs). Code-wise, A and B are the same. |
Beta Was this translation helpful? Give feedback.
-
|
I just received my batch of LM75B's and the first ones seem to work just fine. Setting I suppose you did solder the correct pads for a fixed I2C address as documented in the datasheet:
|
Beta Was this translation helpful? Give feedback.
-
|
Interesting requirement! I checked my LM75B datasheets from 3 different companies, and none mentions the need for soldering the pads. In which one did you find it? No, my pads weren't soldered. |
Beta Was this translation helpful? Give feedback.
-
|
It's in here https://www.nxp.com/docs/en/data-sheet/LM75B.pdf (cross posted) Looking at my breakout board it's clear those address pins are floating. There is no external pull-up resistors other than the I2C interface and SO open drain output. The latter shouldn't be there. |
Beta Was this translation helpful? Give feedback.
-
|
And if all is well you could end up with this:
|
Beta Was this translation helpful? Give feedback.
-
|
;-) I measured the resistance of the address pads on my breakout board against VCC and GND, and in all cases R was inf! So, they were floating. Strange, because breakout board manufacturers usually make thin connections, which can be scratched off, if needed. Even stranger that only NXP is mentioning floating pins, not TI, not Maxim, not Nat.Sem. I have now soldered the pads, installed |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
I am experimenting with I2C devices and noticed a problem with the I2C LM75AD temperature sensor, using the "native" driver xsns_26, index 20 on the I2C DEVICES list. It fails to deliver a proper value every now and then, and returns an exact zero only for several cycles!
I have used this piece of hardware many times before on different systems, and it has never failed. I then added a Berry-programmed driver to the code, and this performed correctly at the times the native driver failed.
In dark-brown is the temperature (left scale, in °C) from the native driver, in light brown from the Berry driver. Both talk to the same I2C device, an LM75B. Berry has correct values, where the native gives 0 (zero).
Here is an example response; first is native driver, 2nd is Berry driver:
statusSNS: ... 'LM75AD': {'Temperature': 0.0}, 'LM75': {'Temp': 20.75}, ...In my experience the LM75 is a very well behaved device; those zeros are strange!
Beta Was this translation helpful? Give feedback.
All reactions