Projects / Pico comfort meter

Pico comfort meter

Intermediate2.2 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. PICO

    Wire the sensor

    VCC to 3V3(OUT), GND, data to GP15 with a 10 kilo-ohm pull-up to 3V3(OUT).

  2. PICO

    Wire the display

    SDA to GP0, SCL to GP1, power at 3.3 V.

  3. PICO10.0 mASSD1306

    Install the ssd1306 module

    Using Thonny packages.

  4. PICO

    Save the program as main.py

    On the Pico.

  5. PICO

    Run it

    Temperature, humidity and a word appear.

  6. PICO

    Breathe gently near the sensor

    Humidity rises and the word may change.

In short

How do you build a pico comfort meter?

A Pico reads a DHT22 and shows temperature and humidity with a plain word for how the air feels: dry, comfortable or damp. You need Raspberry Pi Pico H, DHT22 Sensor, Resistor 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 6 steps and about 130 minutes.

Level
Intermediate
Time
About 130 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
DHT22 VCCPico 3V3(OUT) pin 36Power at 3.3 V
DHT22 GNDPico GND pin 38Ground
DHT22 dataPico GP15 pin 20Data line
10 kilo-ohm resistorBetween data and 3V3(OUT)Pull-up
OLED VCC and GNDPico 3V3(OUT) and GNDPower at 3.3 V
OLED SDA and SCLPico GP0 pin 1 and GP1 pin 2I2C data and clock

Code

The DHT22 measures humidity with a small capacitor whose value changes with moisture, and temperature with a thermistor, and sends both as numbers over one data wire. MicroPython has a dht module that does the timing for you. The sensor is slow, so it is read about every two seconds, and a read can fail, which the program catches and reports. The comfort word is a simple rule: under 30 percent is dry, 30 to 60 is comfortable and above 60 is damp. That is a rough guide for a living room and not advice about health or building damp. Readings are indicative only: a breath or a kettle moves them quickly, and the sensor is a few percent off at best. Keep it away from heat sources and direct sun so the temperature is honest.

import time
import dht
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C

i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
sensor = dht.DHT22(Pin(15))

def feel(h):
    if h < 30:
        return "Dry"
    if h <= 60:
        return "Comfortable"
    return "Damp"

while True:
    try:
        sensor.measure()
        t = sensor.temperature()
        h = sensor.humidity()
        oled.fill(0)
        oled.text("Comfort meter", 0, 0)
        oled.text("Temp: {:.1f} C".format(t), 0, 18)
        oled.text("Humid: {:.0f} %".format(h), 0, 32)
        oled.text(feel(h), 0, 50)
    except OSError:
        oled.fill(0)
        oled.text("Sensor read failed", 0, 24)
    oled.show()
    time.sleep(2)                               # the sensor needs about 2 s between reads

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Room airPlausible values and a word
Breath near the sensorHumidity rises briefly
Unplug the data wireSensor read failed message
Dry air below 30 percentWord shows Dry
Above 60 percentWord shows Damp

If it does not work

Sensor read failed

Check the data pin GP15, the pull-up and 3.3 V power.

ImportError for ssd1306

Install the micropython-ssd1306 package.

Blank screen

Check the OLED address 0x3C and the GP0 and GP1 wires.

Values jump

Keep the sensor away from heat and air flow.

Program does not start on power-up

Save it on the Pico as main.py.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pico comfort meter?

Raspberry Pi Pico H, DHT22 Sensor, Resistor 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points.

How long does the pico comfort meter take to build?

About 130 minutes for a intermediate maker, in 6 steps.

How do I know the pico comfort meter works?

Room air: Plausible values and a word. Breath near the sensor: Humidity rises briefly. Unplug the data wire: Sensor read failed message.

Sensor read failed: what should I check?

Check the data pin GP15, the pull-up and 3.3 V power.

ImportError for ssd1306: what should I check?

Install the micropython-ssd1306 package.

Blank screen: what should I check?

Check the OLED address 0x3C and the GP0 and GP1 wires.

Values jump: what should I check?

Keep the sensor away from heat and air flow.