Comments on: Raspberry Pi: DHT11/DHT22 Temperature and Humidity (Python) https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 07 May 2026 11:34:58 +0000 hourly 1 https://wordpress.org/?v=6.8.5 By: aman https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-1185786 Thu, 07 May 2026 11:34:58 +0000 https://randomnerdtutorials.com/?p=134396#comment-1185786 In reply to Matthew Pollock.

someone can help me to fix DHT11 with Raspberry pi i’m unable to utilise it no data is there only a fatal error
the terminal commands i used for DHT 11

sudo apt update && sudo apt upgrade

cd ~/Desktop

mkdir dht_test

cd ~/Desktop/dht_test

python3 -m venv myenv

ls -l
output
total 4
drwxrwxr-x 5 rpi rpi 4096 May 6 15:02 myenv

source myenv/bin/activate
output
rpi@raspberrypi:~/Desktop/dht_test $ source myenv/bin/activate
(myenv) rpi@raspberrypi:~/Desktop/dht_test $

python3 -m pip install adafruit-circuitpython-dht

code used-
import time
import board
import adafruit_dht

Sensor data pin is connected to GPIO 4

sensor = adafruit_dht.DHT22(board.D4)

Uncomment for DHT11

#sensor = adafruit_dht.DHT11(board.D4)

while True:
try:
# Print the values to the serial port
temperature_c = sensor.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = sensor.humidity
print(“Temp={0:0.1f}ºC, Temp={1:0.1f}ºF, Humidity={2:0.1f}%”.format(temperature_c, temperature_f, humidity))

except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
sensor.exit()
raise error

time.sleep(3.0)

error occur

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File “”, line 2, in
ModuleNotFoundError: No module named ‘board’

someone suggest me how it can get fixed??

]]>
By: Rossen https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-1060740 Wed, 25 Jun 2025 02:21:04 +0000 https://randomnerdtutorials.com/?p=134396#comment-1060740 In reply to Rossen.

Problem solved in Adafruit-Blinka 8.61.2. I just ununstall 8.60.0 andre-run the install again

]]>
By: Rossen https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-1059080 Thu, 19 Jun 2025 14:00:59 +0000 https://randomnerdtutorials.com/?p=134396#comment-1059080 Hi,
I few months ago I had working script, but my SD card has gone. Now I’m trying to reproduce again. Everything is the same, but the script fails with:

(env) termometer@raspberrypi:~/dht22 $ python3 dht_basic.py
Traceback (most recent call last):
File “/home/termometer/dht22/dht_basic.py”, line 5, in
import board
File “/home/termometer/dht22/env/lib/python3.11/site-packages/board.py”, line 21, in
from adafruit_blinka.agnostic import board_id, detector
ModuleNotFoundError: No module named ‘adafruit_blinka’

The dht library is installed as the recmmended:

(env) termometer@raspberrypi:~/dht22 $ python3 -m pip install adafruit-circuitpython-dht
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: adafruit-circuitpython-dht in ./env/lib/python3.11/site-packages (4.0.9)
Requirement already satisfied: Adafruit-Blinka in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-dht) (8.60.0)
Requirement already satisfied: Adafruit-PlatformDetect>=3.70.1 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (3.80.0)
Requirement already satisfied: Adafruit-PureIO>=1.1.7 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.1.11)
Requirement already satisfied: RPi.GPIO in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (0.7.1)
Requirement already satisfied: rpi_ws281x>=4.0.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (5.0.0)
Requirement already satisfied: sysv_ipc>=1.1.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.1.0)
Requirement already satisfied: pyftdi>=0.40.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (0.56.0)
Requirement already satisfied: binho-host-adapter>=0.1.6 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (0.1.6)
Requirement already satisfied: adafruit-circuitpython-typing in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.12.1)
Requirement already satisfied: lgpio>=0.2.2.0 in ./env/lib/python3.11/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (0.2.2.0)
Requirement already satisfied: pyserial in ./env/lib/python3.11/site-packages (from binho-host-adapter>=0.1.6->Adafruit-Blinka->adafruit-circuitpython-dht) (3.5)
Requirement already satisfied: pyusb!=1.2.0,>=1.0.0 in ./env/lib/python3.11/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-dht) (1.3.1)
Requirement already satisfied: adafruit-circuitpython-busdevice in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (5.2.13)
Requirement already satisfied: adafruit-circuitpython-requests in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (4.1.13)
Requirement already satisfied: typing_extensions~=4.0 in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (4.14.0)
Requirement already satisfied: Adafruit-Circuitpython-ConnectionManager in ./env/lib/python3.11/site-packages (from adafruit-circuitpython-requests->adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (3.1.5)

]]>
By: Rem Collier https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-996527 Thu, 02 Jan 2025 07:54:24 +0000 https://randomnerdtutorials.com/?p=134396#comment-996527 In reply to Roger.

Hi,

I am following the tutorial – I had to use thr pulseio=False fix to get it working, but now I get: “A Full Buffer was not returned”. I am using a DHT11 sensor…

Any Ideas?

Many thanks,

Rem

]]>
By: Faris https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-915891 Fri, 17 May 2024 09:36:14 +0000 https://randomnerdtutorials.com/?p=134396#comment-915891 Hi Sara,
I went through all your steps but always fail at running the skript. All errors returned are about failed imports because no such modul exsist. I am a complete beginner and don´t know how to solve the problem.

I would be happy with some help

Best Regards
Faris

]]>
By: Dieter Beer https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-892489 Sun, 18 Feb 2024 16:37:26 +0000 https://randomnerdtutorials.com/?p=134396#comment-892489 In reply to Sara Santos.

Hi Sara, I use a Pi 3B+ with OS 64bit from 2023-12-05. I did a complete new installation. Kind regards Dieter

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-892453 Sun, 18 Feb 2024 11:30:30 +0000 https://randomnerdtutorials.com/?p=134396#comment-892453 In reply to Baps.

Hi.
Can you tell me which Raspberry Pi and which OS are you using?
We didn’t need to run that on our setup.

Regards,
Sara

]]>
By: Baps https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-892402 Sun, 18 Feb 2024 03:40:01 +0000 https://randomnerdtutorials.com/?p=134396#comment-892402 it additionally needed:
(myenv) pi@raspberrypi:~/Desktop/dht_test $ python3 -m pip install RPi.GPIO

else showing error:
ModuleNotFoundError: No module named ‘RPi’

]]>
By: Dieter Beer https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-891594 Thu, 15 Feb 2024 16:34:02 +0000 https://randomnerdtutorials.com/?p=134396#comment-891594 In reply to Sara Santos.

Hi Sara, thanks for your support. The re-installation of the gpio lib solved the problem. As a work around I upfront your hint modified the sketch in that way that it worked without the ‚import board‘ statement. Thanks again ! Dieter

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-dht11-dht22-python/#comment-891492 Thu, 15 Feb 2024 10:39:49 +0000 https://randomnerdtutorials.com/?p=134396#comment-891492 In reply to Dieter Beer.

Hi.
I’m not sure about that error message.
I didn’t face that issue with my setup.
Taking a look at this discussion: https://github.com/adafruit/Adafruit_CircuitPython_DHT/issues/29
It is suggested to run the following command:
sudo apt-get install libgpiod2

Let me know if this solves the issue.
Regards,
Sara

]]>