several ICs on RPI pico #18468
Replies: 12 comments 11 replies
-
How are you powering the setup? The ANS160 (datasheet) draws 79 mA on startup, which might be a little much for a USB-powered sensor board. |
Beta Was this translation helpful? Give feedback.
-
|
To understand you correctly: you write: "I have the ENS on IC0 (pins 0 and 1) and the AHT10 on IC2 (pins 6 and 7). The LCD runs on IC0, pins 16 and 17)". |
Beta Was this translation helpful? Give feedback.
-
|
Two comments on the code:
|
Beta Was this translation helpful? Give feedback.
-
|
OK so I could have: unfortunately if I do that and connecting the working LCD to pins 0 and 1 (along with GND and +5V), using |
Beta Was this translation helpful? Give feedback.
-
|
OK, I moved the ENS160 out, and got the LCD to work. Then I added the ENS and got this: |
Beta Was this translation helpful? Give feedback.
-
|
OK, sorry if I get a lot of "Don't do that!' but I use the 5V VBUS to power all I2Cs, and the 3.3V SDA/SCL from the pi to drive them. Maybe this explains some of the issues I have faced? |
Beta Was this translation helpful? Give feedback.
-
|
It is a question at which voltage level the I2C bus operates. Since the RPI Pico uses 3.3V levels, the bus must be operated at that level. As far as I could tell, the ENS160 and AHT10 use 3.3v Levels. The breakout board include a 5V->3.3V regulator, so you can supply the board with 5.5V, but the I2C signal level is 3.3V. The LCD is different. You must supply it at 5V to get a proper contrast, and the I2C level it expects and attempts to enforce is 5V. To have a clean and reliable bus operation, you then need a level shifter, but only for the LCD. @Flipje1955 showed his approach to it, and you have to do the same. Be cautious: There are different types of level shifters, and some do not work with I2C. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks Robert. I have found many tutorials (including the one with the LCD library (DIYables_MicroPython_LCD_I2C) here: https://newbiely.com/tutorials/raspberry-pico/raspberry-pi-pico-lcd-20x4) that use the 5V VBUS from the pi and the SDA/SCL directly without level shifters. Is it bad practise or just "works well enough for an example"? |
Beta Was this translation helpful? Give feedback.
-
|
BY the way the AHT10 says 1.8 to 6V and the ENS160 is 5V (or 3.3V if using the specific 3.3V on the IC) |
Beta Was this translation helpful? Give feedback.
-
This is bad practice, and it just works, as long as only one I2C device is connected. Assuming a 10kOhm pull-up resistors to 5V, it causes a back current into the Pico GPIO pin of about 100 uA when the level is high. Even if that most of the time will not break the pin circuitry, it is not an intended mode. |
Beta Was this translation helpful? Give feedback.
-
Looking at what is most likely the board that you use: |
Beta Was this translation helpful? Give feedback.
-
|
If the breakout modules you use have a 5V VCC input, and you need 5V anyhow for the LCD, then it's fine to use it. assuming that the I2C bis levels are at 3.3V. If breakout modules do not have a separate regulator, then 3.3V has to be used. The load at the PICO 3V3 pin should not exceed 300mA. Less, if the RP2040 drives other loads as well. The maximum rating for a Pico GPIO pin specified in the data sheet is |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am trying to run my RPI pico with a aht10 for measuring temperature and humidity, and a ENS160+AHT21 for reading the CO2, and a LCD2004 to display the data (I don't use the AHT21 on the ENS160 as its temperature is off by about 10C, as the ENS160 itself is self heating for accurate CO2 measurments). Application is controlling humidity, temperature and CO2 level in a mushroom growing box. All ICs work well separately (LCD alone, or ENS160/AHT21+ LCD, or AHT10 + LCD). The issue starts when I try to use the ENS160/AHT21 and the AHT10 together. They have the same address 0x38 so I have the ENS on IC0 (pins 0 and 1) and the AHT10 on IC2 (pins 6 and 7). The LCD runs on IC0, pins 16 and 17). I thought I could have several ICs on the same port as long as they don't have the same address; after all the ENS160/AHT21 have 2 ICs on IC0. Everytime I try to run all the ICs together I get the error message:
Traceback (most recent call last):
File "", line 29, in
File "/lib/ahtx0.py", line 50, in init
File "/lib/ahtx0.py", line 59, in reset
OSError: [Errno 5] EIO
If I remove the ENS or the AHT10, the program works again. Any hints? Code below, running with RPI_PICO-20250911-v1.26.1
many thanks for your comments!
Tom
AHT+ENS160+LCD.py
import time
from machine import Pin, I2C
from DIYables_MicroPython_LCD_I2C import LCD_I2C
import ahtx0
import AHT21
import ENS160
print ('Hello')
#LCD---------------------------------------------------------
The I2C address of your LCD (Update if different)
I2C_ADDR = 39 # Use the address found using the I2C scanner
Define the number of rows and columns on your LCD
LCD_COLS = 20
LCD_ROWS = 4
Create I2C object, Initialize I2C
i2c_lcd = I2C(0, sda=16, scl=17, freq=400000)
time.sleep(1)
lcd = LCD_I2C(i2c_lcd, I2C_ADDR, LCD_ROWS, LCD_COLS)
#LCD---------------------------------------------------------
#AHT---------------------------------------------------------
Create I2C object
#make sure to select 0 or 1 depending on which SCL/SDA is selected
i2c_aht = I2C(1, scl=7, sda=6)
time.sleep(1)
Create the sensor object using I2C
aht = ahtx0.AHT10(i2c_aht)
#AHT---------------------------------------------------------
#ENS160---------------------------------------------------------
Create I2C object
#make sure to select 0 or 1 depending on which SCL/SDA is selected
i2c_ens_aht = I2C(0, sda=0, scl=1)
time.sleep(1)
aht_ens = AHT21.AHT21(i2c_ens_aht)
ens = ENS160.ENS160(i2c_ens_aht)
ens.reset()
time.sleep(0.5)
ens.operating_mode = 2
time.sleep(2.0)
#ENS160---------------------------------------------------------
print("LCD: ",i2c_lcd.scan())
print("AHT: ",i2c_aht.scan())
#print("ENS_AHT: ", i2c_ens_aht.scan())
Define all Pins
led = Pin("LED", Pin.OUT)
#check Pins
led.on()
time.sleep(0.5)
led.off()
time.sleep(0.5)
led.on()
Setup function
lcd.backlight_on()
lcd.clear()
for i in range (0, 100):
temperature = round(aht.temperature, 2)
humidity = round(aht.relative_humidity, 2)
print (i)
lcd.clear()
lcd.set_cursor(0, 0) # Move cursor at the first row, first column
lcd.print('working '+ str(i)) # Display text at the first row
lcd.set_cursor(0, 1) # Move cursor at the first row, first column
lcd.print('temperature: '+ str(temperature))
lcd.set_cursor(0, 2) # Move cursor at the first row, first column
lcd.print('humidity: '+ str(humidity))
lcd.set_cursor(0, 3) # Move cursor at the first row, first column
lcd.print('working '+ str(i))
led.toggle()
time.sleep(1)
Beta Was this translation helpful? Give feedback.
All reactions