Skip to content

Commit d122696

Browse files
committed
tweak to RPi pulse detect
1 parent de4f5f3 commit d122696

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_dht.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def _get_pulses(self):
145145
dhtval = not dhtval # we toggled
146146
transitions.append(time.monotonic()) # save the timestamp
147147
# convert transtions to microsecond delta pulses:
148-
for i in range(1, len(transitions)):
148+
# use last 81 pulses
149+
transition_start = max(1, len(transitions) - 81)
150+
for i in range(transition_start, len(transitions)):
149151
pulses_micro_sec = int(1000000 * (transitions[i] - transitions[i-1]))
150152
pulses.append(min(pulses_micro_sec, 65535))
151153
return pulses

0 commit comments

Comments
 (0)