Skip to content

Commit ced0804

Browse files
committed
Reject humidity outside of range (0, 100) as unplausible
1 parent 142f395 commit ced0804

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
@@ -214,6 +214,10 @@ def measure(self):
214214
# check sum failed to validate
215215
raise RuntimeError("Checksum did not validate. Try again.")
216216

217+
if new_humidity < 0 or new_humidity > 100:
218+
# We received unplausible data
219+
raise RuntimeError("Received unplausible data. Try again.")
220+
217221
elif len(pulses) >= 10:
218222
# We got *some* data just not 81 bits
219223
raise RuntimeError("A full buffer was not returned. Try again.")

0 commit comments

Comments
 (0)