Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 21513

MicroPython • Re: AHTx0 sensor with Pico W

$
0
0
Hi, I am running into the same issue, but have been unable to resolve it. When I run i2C_scan.py, if finds my AHT20

MPY: soft reboot
Number of I2C devices found= 1
Device Hexadecimel Address= 0x38

And when I run ahtx0.py I do not get any errors.

However, when I run aht20.py I get the following:

MPY: soft reboot
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/lib/ahtx0.py", line 51, in __init__
File "/lib/ahtx0.py", line 60, in reset
OSError: [Errno 5] EIO

my code for aht20.py is as follows:

Code:

# AHT20 Temp,RH sensor on Pi Pico / micropythonimport utimefrom machine import Pin, I2Cimport ahtx0i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000)sensor = ahtx0.AHT20(i2c)print("degC, %RH")while True:    print("%0.2f, %0.2f" %          (sensor.temperature,          sensor.relative_humidity))    utime.sleep(5)    
I am using a pico W and have tried
sensor = ahtx0.AHT10(i2c) and sensor = ahtx0.AHT20(i2c)
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000) - these are the pins my AHT20 are attached to and i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000) per the example.

All variations produce the same error. So, I am stuck - any help is greatly appreciated.

Statistics: Posted by grod55 — Tue Apr 01, 2025 12:26 am



Viewing all articles
Browse latest Browse all 21513

Trending Articles