Skip to content

Commit f61a510

Browse files
committed
Update adafruit_dht.py
Catch the exception raised by blinka.
1 parent bcf4206 commit f61a510

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

adafruit_dht.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import array
3232
import time
3333
from os import uname
34-
from digitalio import DigitalInOut, Direction
34+
from digitalio import DigitalInOut, Pull, Direction
3535

3636
_USE_PULSEIO = False
3737
try:
@@ -160,7 +160,15 @@ def _get_pulses_bitbang(self):
160160
timestamp = time.monotonic() # take timestamp
161161
dhtval = True # start with dht pin true because its pulled up
162162
dhtpin.direction = Direction.INPUT
163-
dhtpin.pull = None
163+
164+
try:
165+
dhtpin.pull = Pull.UP
166+
# Catch the NotImplementedError raised because
167+
# blinka.microcontroller.generic_linux.libgpiod_pin does not support
168+
# internal pull resistors.
169+
except NotImplementedError:
170+
dhtpin.pull = None
171+
164172
while time.monotonic() - timestamp < 0.25:
165173
if dhtval != dhtpin.value:
166174
dhtval = not dhtval # we toggled

0 commit comments

Comments
 (0)