Answers for "DHT22 raspberry pi zero connector"

0

DHT22 raspberry pi zero connector

import Adafruit_DHT

DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4

while True:
    humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)

    if humidity is not None and temperature is not None:
        print("Temp={0:0.1f}*C  Humidity={1:0.1f}%".format(temperature, humidity))
    else:
        print("Failed to retrieve data from humidity sensor")
Posted by: Guest on September-05-2020

Python Answers by Framework

Browse Popular Code Answers by Language