DHT-Blinka fail when using libgpiod
See original GitHub issueI 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Problem using libgpiod - Raspberry Pi Forums
It's a Linux library. It will be using Broadcom GPIO numbers (not pin numbers). But how do I now how to map the...
Read more >libgpiod
libgpiod. libgpiod - C library and tools for interacting with the linux GPIO character device. Since linux 4.8 the GPIO sysfs interface is...
Read more >gpio - libgpiod read value Operation not permitted
Trying to read the values from gpio chips in a Python script using the gpiod python module. When calling get_value() ...
Read more >GPIO Programming: Exploring the libgpiod Library | ICS
In this blog post we'll look at libgpiod, a C library and tools for interacting with the Linux GPIO hardware.
Read more >How to control a GPIO in userspace - stm32mpu - ST Wiki
1 Purpose; 2 GPIO control through libgpiod; 3 GPIO control through your own ... 0); if (fd == -1) { ret = -errno;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 🐣 🤩