Python Tutorials – Lesson 8 – Humidity Sensor on Raspberry Pi Pico

To control Humidity Sensor using Raspberry Pi Pico

Required Components

  1. Humidity Sensor (DHT11)_1 no
  2. Raspberry Pi Pico Board_1 no
  3. Connecting wires_1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Raspberry Pi Pico board GP16th pin to the Humidity Sensor.
  3. Connect Humidity Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
  4. Check the Electrical Circuit.
  5. Check the Python program.
  6. 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)

Leave a Reply

Your email address will not be published. Required fields are marked *