Files
loustique-home/composants/byPanda/DHT11.py

17 lines
331 B
Python
Raw Normal View History

import Adafruit_DHT as dht
import time as t
2026-03-30 23:17:08 +02:00
import RPi.GPIO as GPIO
2026-03-30 23:17:08 +02:00
GPIO.setmode(GPIO.BOARD)
capteur = dht.DHT11
pin = 22
2026-03-30 23:17:08 +02:00
def lire_temperature():
humidite, temperature = dht.read_retry(capteur, pin)
if temperature is not None:
print("Temp :", temperature, "°C")
else:
print("Erreur")
t.sleep(2)