Retry when DHT temp sensor read fails #455

Merged
markleary merged 1 commits from master into master 2022-01-02 21:27:34 +00:00
markleary commented 2021-12-15 15:57:27 +00:00 (Migrated from github.com)

DHT sensor reads fail fairly often, causing the enclosure plugin to report a value of 0. When this happens, octoprint logs the exception:

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/getDHTTemp.py", line 19, in <module>
     humidity = dht_dev.humidity
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_dht.py", line 284, in humidity
     self.measure()
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_dht.py", line 230, in measure
    raise RuntimeError("A full buffer was not returned. Try again.")
RuntimeError: A full buffer was not returned. Try again.

This seem to be a well known issue, the adafruit_dht docs recommend catching the failed read exception and retrying. I no longer get false 0 degree readings with this change.

DHT sensor reads fail fairly often, causing the enclosure plugin to report a value of 0. When this happens, octoprint logs the exception: ``` Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/getDHTTemp.py", line 19, in <module> humidity = dht_dev.humidity File "/home/pi/.local/lib/python3.7/site-packages/adafruit_dht.py", line 284, in humidity self.measure() File "/home/pi/.local/lib/python3.7/site-packages/adafruit_dht.py", line 230, in measure raise RuntimeError("A full buffer was not returned. Try again.") RuntimeError: A full buffer was not returned. Try again. ``` This seem to be a well known issue, the adafruit_dht docs recommend catching the failed read exception and retrying. I no longer get false 0 degree readings with this change.
mattia952 commented 2024-04-21 18:16:31 +01:00 (Migrated from github.com)

the error are in python script getDHTTemp.py in octoprint_enclosure directory!
maybe adafruit_dht library change from last review. for fixing i this dictionary:

'5': board.D5
'6': board.D6
'7': board.D7
'8': board.D8
'9': board.D9
'10': board.D10
'11': board.D11
'12': board.D12
'13': board.D13
'14': board.D14
'15': board.D15
'16': board.D16
'17': board.D17
'18': board.D18
'19': board.D19
'20': board.D20
'21': board.D21
'22': board.D22
'23': board.D23
'24': board.D24
'25': board.D25
'26': board.D26
'27': board.D27

and define pin = board_pin[sys.argv[2]]

now the line: dht_dev = sensor(pin)
works correctly

the error are in python script getDHTTemp.py in octoprint_enclosure directory! maybe adafruit_dht library change from last review. for fixing i this dictionary: '5': board.D5 '6': board.D6 '7': board.D7 '8': board.D8 '9': board.D9 '10': board.D10 '11': board.D11 '12': board.D12 '13': board.D13 '14': board.D14 '15': board.D15 '16': board.D16 '17': board.D17 '18': board.D18 '19': board.D19 '20': board.D20 '21': board.D21 '22': board.D22 '23': board.D23 '24': board.D24 '25': board.D25 '26': board.D26 '27': board.D27 and define pin = board_pin[sys.argv[2]] now the line: dht_dev = sensor(pin) works correctly
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#455