Adafruit_CircuitPython_DHT: DHT-Blinka fail when using libgpiod
I just wanted to test the DHT22 sensor as in https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/python-setup but first test the functionality of Blinka.
Also I just encountered this using digitalio.DigitalInOut
:
In [9]: dhtDevice = adafruit_dht.DHT22(pin)
In [10]: dhtDevice.temperature
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-bb6e5b54f869> in <module>()
----> 1 dhtDevice.temperature
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in temperature(self)
225 data returned from the device (try again)
226 """
--> 227 self.measure()
228 return self._temperature
229
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in measure(self)
179 pulses = self._get_pulses_pulseio()
180 else:
--> 181 pulses = self._get_pulses_bitbang()
182 #print(len(pulses), "pulses:", [x for x in pulses])
183
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in _get_pulses_bitbang(self)
135 """
136 pulses = array.array('H')
--> 137 with DigitalInOut(self._pin) as dhtpin:
138 # we will bitbang if no pulsein capability
139 transitions = []
/usr/local/lib/python3.7/dist-packages/digitalio.py in __init__(self, pin)
82
83 def __init__(self, pin):
---> 84 self._pin = Pin(pin.id)
85 self.direction = Direction.INPUT
86
AttributeError: 'DigitalInOut' object has no attribute 'id'
and using the board.PXX
I get this:
In [1]: import board
In [2]: import adafruit_dht
In [3]: dhtDevice = adafruit_dht.DHT22(board.PC4)
In [4]: dhtDevice.temperature
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-4-bb6e5b54f869> in <module>()
----> 1 dhtDevice.temperature
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in temperature(self)
225 data returned from the device (try again)
226 """
--> 227 self.measure()
228 return self._temperature
229
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in measure(self)
179 pulses = self._get_pulses_pulseio()
180 else:
--> 181 pulses = self._get_pulses_bitbang()
182 #print(len(pulses), "pulses:", [x for x in pulses])
183
/usr/local/lib/python3.7/dist-packages/adafruit_dht.py in _get_pulses_bitbang(self)
147 dhtval = True # start with dht pin true because its pulled up
148 dhtpin.direction = Direction.INPUT
--> 149 dhtpin.pull = Pull.UP
150 while time.monotonic() - timestamp < 0.25:
151 if dhtval != dhtpin.value:
/usr/local/lib/python3.7/dist-packages/digitalio.py in pull(self, pul)
137 self.__pull = pul
138 if pul is Pull.UP:
--> 139 self._pin.init(mode=Pin.IN, pull=Pin.PULL_UP)
140 elif pul is Pull.DOWN:
141 if hasattr(Pin, "PULL_DOWN"):
/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py in init(self, mode, pull)
45 if pull != None:
46 if pull == self.PULL_UP:
---> 47 raise NotImplementedError("Internal pullups not supported in libgpiod, use physical resistor instead!")
48 elif pull == self.PULL_DOWN:
49 raise NotImplementedError("Internal pulldowns not supported in libgpiod, use physical resistor instead!")
NotImplementedError: Internal pullups not supported in libgpiod, use physical resistor instead!
Is it possible to set a different pull on pin? Let’s say I have already connected the physical resistor on the sensor.
More details:
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> board.detector.chip.id
'SUN8I'
>>> board.detector.board.id
'ORANGE_PI_PLUS_2E'
>>>
This relates to: https://github.com/adafruit/Adafruit_Blinka/issues/245
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (1 by maintainers)
Commits related to this issue
- Fix issue #32 — committed to yeyeto2788/Adafruit_CircuitPython_DHT by yeyeto2788 4 years ago
- Merge pull request #56 from yeyeto2788/fix_issue_32 Fix issue #32 — committed to adafruit/Adafruit_CircuitPython_DHT by ladyada 4 years ago
@dherrada, @makermelissa maybe a possible solution would be:
bool
variable to suppress warnings and just pass over the exception if it is set up on this lines within Blinka.@SecT0uch both DHT11 modules I used had the resistor on it. The board seems like it does not have a built-in pull resistor as per the datasheet and I could also not see any information regarding PWM but I guess it can be simulated somehow. BTW sorry for not replying earlier to your questions.
If there something else needed on my side just let me know.
Hey! Another update.
I finally got to read at least once 😃 with another sensor (Seems like the other one was defective) SEE TRY NUMBER 9:
So it is actually returning 81 pulses and several tries but it only converts one of the tries with the same 81 pulses.
Script I used below, I wanted to make sure there was a delay regardless of it read process was right or not.
EDIT: it actually worked more than once 🐣 🤩