-
Notifications
You must be signed in to change notification settings - Fork 62
Improve error handling #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hmm! nice idea - would you mind pylinting? you probably just need to add a '# pylint: disable' line |
We can actually reduce the number of branches by checking for any missing bits first. Then the main decoding logic does not need to be wrapped by an |
ok and ya tested on a pi? which ones? we'll test too :) |
It's running here (in combination with adafruit/libgpiod_pulsein#1) on a Raspberry Pi 4B and taking one measurement each minute. Looks good so far. Of course the most recent version now only runs for an hour or so but I will continue observing it over the next days. |
Just a quick follow-up: The most recent version has been running here for more than three days now, taking over 4000 successful measurements without returning any garbage. Of course it can still return garbage if just the wrong two bits flip in the communication. There's nothing we can do about that. |
thanks, we're a little swamped, but not forgotten! |
@ladyada Could you please merge the fix. |
I tested this with a Trinket M0 and a DHT11. Ran for about an hour taking readings every 2 seconds. I did see the bogus data error a few times. But I think it was my fault in those cases the sensor was not connected properly yet. Since getting connected correctly it's run successfully and been reporting temperature and humidity. It does need to have some merge conflicts resolved now though. @michaellass if you are able to you can make a new commit here to resolve them. If not, no worries I will try to work on getting it resolved later this week. |
Currently, we update self._temperature and self._humidity, even if it turns out that the data returned by the sensor was bogus. If the user queries the data within two seconds after an error, they will actually get wrong data. Fix this by updating _temperature and _humidity attributes only if no error was detected.
024c454
to
efda9b8
Compare
Thanks for testing! I just rebased the changes onto master. |
Thank you michaellass this contribution and for rebasing. Following up on testing, my Trinket M0 + DHT11 continued to run all night over night with no serious issues. It looks like this was originally made to resolve an issue when running under Pi / Blinka. I will try to get it tested that way later this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully with Raspberry Pi 3B. This does properly filter out erroneous data reads from the sensor.
Updating https://github.com/adafruit/Adafruit_CircuitPython_DHT to 3.4.0 from 3.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_DHT#31 from michaellass/error_handling Updating https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731 to 2.6.1 from 2.6.0: > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3731#25 from dglaude/patch-1
adafruit/Adafruit_Blinka#210 demonstrated erroneous readings that can easily be avoided: