exxamalte / esphome-customisations

ESPHome customisations.
Apache License 2.0
20 stars 8 forks source link

shows the maximum temperature +1037°C #1

Closed necton closed 2 years ago

necton commented 3 years ago

Updated to the latest version, sensor readings are the maximum possible value...

Log: [20:51:35][W][mlx90614:031]: Ambient temperature out of range: 1037.549927 [20:51:35][W][mlx90614:040]: Object temperature out of range: 1037.549927

exxamalte commented 3 years ago

I remember having issues with the temperature readings occasionally, hence I added that code which essentially discards any readings outside of the sensor's specs (https://www.melexis.com/-/media/files/documents/datasheets/mlx90614-datasheet-melexis.pdf).

Do you get these readings all the time, or only occasionally?

exxamalte commented 3 years ago

Here a little further analysis: I looked into the underlying Adafruit library, method readTemp to see how that weird value could show up over and over. (1037.549927 + 273.15) * 0.02 = 65535 = 0xFFFF. That looks very suspicious.

There was a report https://github.com/adafruit/Adafruit-MLX90614-Library/issues/15 that saw temperature on the other end of the spectrum and was suspected a wiring issue. Maybe the same is true for the high value that you are getting from your sensor?

Jamiro75 commented 2 years ago

i've tested and is working, but with a workaround, the error readings is more frequentlly and i'm solve, make more that one reading sequential, and the error decrese a lot, es. in the file mlx90614_sensor.h .... double ambient_temperature = mlx.readAmbientTempC(); ambient_temperature = mlx.readAmbientTempC(); ambient_temperature = mlx.readAmbientTempC(); ..... double object_temperature = mlx.readObjectTempC(); object_temperature = mlx.readObjectTempC(); object_temperature = mlx.readObjectTempC(); .... the solutution is cicle while if error with a max of 10 times but form me this simple workaround is ok i think is possible timing problem that cause that.

in the principal yaml i forced the bus i2c at 50khz too

this is my personal test

exxamalte commented 2 years ago

Thanks @Jamiro75, I followed your advice and implemented a simple retry when reading values from the sensor. In my tests I always got a proper value at the second attempt, so I limited to number of retries to 5 for now.