Skip to content

Commit e6880d7

Browse files
committed
Reject humidity outside of range (0, 100) as unplausible
1 parent 1833318 commit e6880d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_dht.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ def measure(self):
221221
# check sum failed to validate
222222
raise RuntimeError("Checksum did not validate. Try again.")
223223

224+
if new_humidity < 0 or new_humidity > 100:
225+
# We received unplausible data
226+
raise RuntimeError("Received unplausible data. Try again.")
227+
224228
elif len(pulses) >= 10:
225229
# We got *some* data just not 81 bits
226230
raise RuntimeError("A full buffer was not returned. Try again.")

0 commit comments

Comments
 (0)