padelt/temper-python

Temperature reading near zero read near 255.

marklewis3000 opened this issue · 3 comments

I put my TEMPer device in an ice bath. I set the /etc/temper.conf file scale=1.0 and offset=0.0 to uncalibrate it. As it cools in the ice bath, the degrees C readings go as 1.3, 0.8, 0.3, 255.9, 255.6. In other words, when it reaches 0.0 degrees, you have to subtract off 256 (still uncalibrated). These values of course mess with the degrees F as well, which respectively show as 34.4, 33.4, 32.6, 492.7, 492.0 !!

Since the advertise device range is -40 to 120 degrees C, I think you need to have a check in the code, after fetching the data at line 268 of temper.py,

  •                 celsius = data[offset] + data[offset+1] / 256.0
    

something like

  •     if celsius >= 128:
             celsius = celsius - 256
    

Details of the TEMPer device are given here:
https://sigrok.org/wiki/RDing_TEMPer_Gold#Resources
Which says, theTemperature sensor is a NXP LM75A.
Data sheet can be found here:
http://www.nxp.com/documents/data_sheet/LM75A.pdf

Temperatures range from −55° C to +125°C
11-bit ADC (2's complement number) that offers a temperature resolution of 0.125°C (3 bits).
The most significant bits are in byte 0, and the top 3 bits of byte 1 are the 1/8th degree C part.

smeek commented

I've got a pull request (#68) open for a fix to this issue.

This should be fixed in the new master-version. This is not released on PyPI yet.
@marklewis3000 Please test again and re-open the issue if there are further problems!