To control Humidity Sensor using Raspberry Pi Pico
Required Components
- Humidity Sensor (DHT11)_1 no
- Raspberry Pi Pico Board_1 no
- Connecting wires_1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the Raspberry Pi Pico board GP16th pin to the Humidity Sensor.
- Connect Humidity Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
- Check the Electrical Circuit.
- Check the Python program.
- Run the Python program.
Python Program
from machine import Pin
import time
from dht import DHT11, InvalidChecksum
sensor = DHT11(Pin(16, Pin.OUT, Pin.PULL_DOWN))
while True:
temp = sensor.temperature
humidity = sensor.humidity
print("Temperature: {}°C Humidity: {:.0f}% ".format(temp, humidity))
time.sleep(2)