MantisIDE

Temperature and humidity (DHT22)

Guide by MantisIDE Team · Fri Nov 27 2026 · 0 points · 0 comments

Read a DHT22 (or DHT11) every 2 seconds.

A starter program from the MantisIDE Full IDE (Tools › Examples). Press Open in Full IDE to run it on your board, change it, and save it as your own.

# Read a DHT22 (or DHT11) every 2 seconds.
import dht
from machine import Pin
import time

sensor = dht.DHT22(Pin(15))

while True:
    sensor.measure()
    print("temp:", sensor.temperature(), "humidity:", sensor.humidity())
    time.sleep(2)
Loading post…

Dialog