I followed this tutorial to setup DHT22 thermal sensor on a raspberry pico: https://peppe8o.com/dht11-humidity-and-temperature-sensor-with-raspberry-pi-pico-and-micropython/?unapproved=7929&moderation-hash=06e75605461fa63372815fc1bebd285f#comment-7929 which uses this class to drive the sensor: https://raw.githubusercontent.com/ikornaselur/pico-libs/master/src/dht11/dht.py

But I'm getting the following error:

"Expected 84 but got 2 pulses"

which is defined in line 98 of the DHT class.

I'm running the sensor with the following code:

from machine import Pin
import utime as time
from DHT11 import DHT11, InvalidChecksum
dhtPIN = 15
dhtSensor = DHT11(Pin(dhtPIN, Pin.OUT, Pin.PULL_DOWN))

while True:
    print("Temp: {}°C".format(dhtSensor.temperature), \
          "| Hum: {0:.1%}".format(dhtSensor.humidity/100))

One thing, the pins in my pico are not soldered, but even if I push the pico down the error keeps coming.

  • 2
    please format the code
    – jsotola
    Commented Nov 7, 2021 at 16:37
  • The github lib seems for PyBoard DHT11. Are you sure it works for Rpi Pico DHT22?
    – tlfong01
    Commented Nov 8, 2021 at 5:58
  • that could indeed be the problem! do I need to do small edit in the code or I should find another library at all?
    – Bakaburg
    Commented Nov 8, 2021 at 8:46

1 Answer 1


You should not expect a DHT22 loosely connected to a Pico to work. You need secure soldered connections.

  • 1
    is that error what you would expect from unstable connections?
    – Bakaburg
    Commented Nov 7, 2021 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.