1

I'm new to the raspberry Pi Pico.

I've been programming my Pico in micropython to use a DHT20 temperature and humidity sensor, using the library given in the seeedwiki I can't get it to work using the code they give me as seen below:

from machine import I2C
from dht20 import DHT20
i2c = I2C(0)
dht20 = DHT20(i2c)
while True:
    temper = dht20.dht20_temperature()
    humidity = dht20.dht20_humidity()
    print("temper : " + str(temper))
    print("humidity : " + str(humidity))

Using the code above with the dht20 library results in this error

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "dht20.py", line 6, in __init__
  File "dht20.py", line 25, in dht20_read_status
OSError: [Errno 5] EIO

The dht20 library can be found in this file:

Grove - Temperature & Humidity Sensor V2.0(DHT20)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Daan Bos
  • 27
  • 3
  • 1
    Please don't post images of code or errors; see [ask]. – Robert Sep 04 '22 at 18:01
  • 1
    I think [this](http://47.106.166.129/Embeded/pico-micropython-grove/blob/master/I2C/dht20.py) is the `dht20.py` library you're using. It looks like `dht20_read_status` is just a [simple I2C read operation](http://47.106.166.129/Embeded/pico-micropython-grove/blob/master/I2C/dht20.py#L25). Ignoring the `dht20` library, can you get that i2c read to work? If not, you may have a wiring problem. – larsks Sep 04 '22 at 21:19
  • 1
    It turned out to be a wiring problem, I didn't have a grasp of how I2C pins work, in combination with trying to fix the code first instead of the wiring it i couldn't resolve it easily. Now it has been resolved – Daan Bos Sep 05 '22 at 12:02

1 Answers1

0

Have a look at https://github.com/flrrth/pico-dht20

It works. MicroPython Module for DHT20 plus example

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 31 '22 at 11:19