Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion adafruit_dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ def measure(self):
delay_between_readings = 0.5
if self._dht11:
delay_between_readings = 1.0
if time.monotonic()-self._last_called > delay_between_readings:
# Initiate new reading if this is the first call or if sufficient delay
# If delay not sufficient - return previous reading.
# This allows back to back access for temperature and humidity for same reading
if (self._last_called == 0 or
(time.monotonic()-self._last_called) > delay_between_readings):
self._last_called = time.monotonic()

pulses = self._get_pulses()
Expand Down