How to Fix "OSError: [Errno 5] EIO" in STM32 Water Quality Monitoring System?
Hello Guys I am trying to develop a real-time water quality monitoring system using an STM32 microcontroller, MicroPython, and various water quality sensors(pH sensor, Turbidity sensor)
DS18B20
. The system will use an AI model to predict water quality parameters such as pH, turbidity, and temperature, and display the results on an LCD
screen. I have connected the pH sensor, turbidity sensor, and DS18B20
temperature sensor to the STM32
, also connected the LCD
screen to the STM32
using I2C
.
But am getting the error
OSError: [Errno 5] EIO
5 Replies
Here's my code
@Enthernet Code the
OSError: [Errno 5] EIO
is typically an input/output error
, which can be caused by several factors. Let's go through some likely solutions:
Firstly, make sure that the I2C
bus initialization is correct. The i2c_bus parameter
in the LCD
initialization should match the I2C
bus number used in your setup. For example, if you're using I2C1
, it should be i2c_bus=1
, Also, verify that the I2C
address (0x27
) is correct for your LCD
screen. You can use an I2C
scanner script to detect the connected I2C
devices and confirm their addresses. Here’s an example of an I2C scanner script:
make sure there is enough delay between
I2C
operations to avoid bus collisions. You can add small delays using time.sleep_ms(10)
between I2C
operations.Since you are using multiple sensors and an LCD on the I2C bus, check if there are any conflicts or interference between devices. Sometimes, devices can cause issues if they are not properly initialized or if they have different voltage levels. Ensure all devices are operating at the same voltage level, preferably
3.3V
for the STM32
, Make sure the libraries for the sensors and the LCD are correctly installed and compatible with your MicroPython setup. Sometimes, library issues can cause unexpected errors and try isolating each sensor and the LCD to check if they work individually. This can help identify if a specific device is causing the issue.Thanks for the guidance @RED HAT @Dark AI i would implement the following corrections and give u guys feedback