Skip to content

DHT-Blinka fail when using libgpiod #32

Closed
@yeyeto2788

Description

@yeyeto2788

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: adafruit/Adafruit_Blinka#245

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions