Howto connect Raspberry Pi to DHT 11 / DHT 22
Connect your DHT11 sensor to the Pico accordingly -
Left pin (Signal) - GPIO Pin 22 (or any of your choosing) Middle pin (Positive) - 3v3 Out Right Pin (Negative) - GND pin
For DHT22 do flip position of pins mentioned on top
(NOTE: If not using a DHT breakout board, connect a 4.7K ohm resistor to signal pin)
Code -
from machine import Pin
import dht
from time import sleep
sensor=dht.DHT11(Pin(22))
while True:
sensor.measure()
print(sensor.temperature())
print(sensor.humidity())
sleep(2)
No comments:
Post a Comment