timofurrer / w1thermsensor

A Python package and CLI tool to work with w1 temperature sensors like DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other devices.
MIT License
491 stars 113 forks source link

Weird behavior with DS18B20 #114

Open sdiama opened 2 years ago

sdiama commented 2 years ago

Erroneous Behavior

I run a "while/true loop" (every 5 seconds) to read the temperatures from multiple DS18B20 sensors. When I disconnect the pin of one sensor from the breadboard, in order to emulate a cable/sensor problem, the "get_temperature()" method returns big negative numbers (ex. -109.9375, -110.1875) for multiple readings (10+ readings) before a "w1thermsensor.errors.SensorNotReadyError" exception is thrown.

Expected Behavior

"w1thermsensor.errors.SensorNotReadyError" exception to be thrown as soon as the sensor disconnected

Steps to reproduce

Unpin a DS18B20 sensor while in a while/true loop

Version

2.0

Python Version

3.9.2

Operating System

Raspberry Pi

Guidelines

timofurrer commented 2 years ago

Hey @sdiama ! w1thermsensor is based on the w1 therm kernel modules in a sense that it reads from the files it exposes in /sys. Therefore, can you check the sensor file in /sys/bus/w1/devices and post its output here?

I'm curious to what it will contain in your case, before it isn't ready any longer.

sdiama commented 2 years ago

3 days now I'm trying to reproduce the error by removing pins, of multiple sensors in my test breadboard and I cannot get the same error! Maybe it was a sensor fault? I made some changes to my code. If a temperature below of -20 is returned by "get_temperature()" method (they are ambient sensors), then I also read the /sys/bus/w1/devices/xxxxxxx/w1_slave and write it to a log file, in order to give you better feedback in the future.