adafruit / Adafruit_CircuitPython_DHT

CircuitPython support for DHT11 and DHT22 type temperature/humidity devices
MIT License
184 stars 64 forks source link

Raspberry Pi 5 - Import error - All GPIO related operation #96

Open the1bit opened 11 months ago

the1bit commented 11 months ago

Script Command

import time
import adafruit_dht
import board

dht_device = adafruit_dht.DHT11(board.D4)

temperature_c = dht_device.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dht_device.humidity
print("Temp:{:.1f} C / {:.1f} C    Humidity: {}%".format(temperature_c, temperature_f, humidity))

Operating System

6.1.0-rpi7-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux

Hardware

Raspberry Pi 5 Model B

Behavior

`ImportError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/user/development/python/dht11/dht11.py", line 2, in import adafruit_dht File "/home/user/development/python/dht11/env/lib/python3.11/site-packages/adafruit_dht.py", line 32, in from digitalio import DigitalInOut, Pull, Direction File "/home/user/development/python/dht11/env/lib/python3.11/site-packages/digitalio.py", line 27, in from adafruit_blinka.microcontroller.bcm2712.pin import * File "/home/user/development/python/dht11/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 5, in from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin File "/home/user/development/python/dht11/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py", line 8, in raise ImportError( ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/libgpiod.sh`

Description

I want to read data from DHT11 sensor. (https://pimylifeup.com/raspberry-pi-dht11-sensor/)

I've installed everything on the right way, nevertheless I cannot read any data.

I cannot do any operation on GPIO. Neither sensors nor relays.

Additional information

No response

tekktrik commented 8 months ago

Hi, the code in this area has changed slightly. does upgrading Blinka help? When you upgrade, you may still be prompted to install libgpiod python bindings; clicking that link will take you to the Installer Script library to install and the specific script you will need to use. The library README in the repository has general installation and usage instructions.