Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update adafruit_dht.py
Catch the exception raised by blinka.
  • Loading branch information
yeyeto2788 committed Dec 14, 2020
commit f61a5103382e96571597661d1b9b4345bdd171f6
12 changes: 10 additions & 2 deletions adafruit_dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import array
import time
from os import uname
from digitalio import DigitalInOut, Direction
from digitalio import DigitalInOut, Pull, Direction

_USE_PULSEIO = False
try:
Expand Down Expand Up @@ -160,7 +160,15 @@ def _get_pulses_bitbang(self):
timestamp = time.monotonic() # take timestamp
dhtval = True # start with dht pin true because its pulled up
dhtpin.direction = Direction.INPUT
dhtpin.pull = None

try:
dhtpin.pull = Pull.UP
# Catch the NotImplementedError raised because
# blinka.microcontroller.generic_linux.libgpiod_pin does not support
# internal pull resistors.
except NotImplementedError:
dhtpin.pull = None

while time.monotonic() - timestamp < 0.25:
if dhtval != dhtpin.value:
dhtval = not dhtval # we toggled
Expand Down