I'm trying to read the data from my DHT11 sensor, which is connected to GPIO-12 (Pin-32). First, I wrote a Python script using the Adafruit_DHT library, but when I start the script, this error occurs. This is what I get:
Traceback (most recent call last):
File "/home/amir-pi/Wetter_Projekt/Adafruit_Python_DHT-1.4.1/test1.py", line 8, in <module>
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/amir-pi/Wetter_Projekt/Adafruit_Python_DHT-1.4.1/Adafruit_DHT/common.py", line 94, in read_retry
humidity, temperature = read(sensor, pin, platform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/amir-pi/Wetter_Projekt/Adafruit_Python_DHT-1.4.1/Adafruit_DHT/common.py", line 80, in read
platform = get_platform()
^^^^^^^^^^^^^^
File "/home/amir-pi/Wetter_Projekt/Adafruit_Python_DHT-1.4.1/Adafruit_DHT/common.py", line 63, in get_platform
raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.
I have tried multiple solutions, such as reinstalling the library, updating the library, or moving and starting the script from the Adafruit_DHT directory.
import Adafruit_DHT
# Sensor-Typ und Pin konfigurieren (DHT11, Pin 32)
sensor = Adafruit_DHT.DHT11
pin = 12
# Versuche, die Temperatur und Luftfeuchtigkeit vom Sensor zu lesen
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
# Überprüfe, ob die Daten erfolgreich gelesen wurden
if humidity is not None and temperature is not None:
print('Temperatur={0:0.1f}°C Luftfeuchtigkeit={1:0.1f}%'.format(temperature, humidity))
else:
print('Fehler beim Lesen der Daten vom Sensor. Versuche es erneut!')