Skip to content

Fix potential first read issue #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 16, 2018
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