Best Way to Log Data from Multiple I2C Sensors with Raspberry Pi Pico

Hi everyone,

I’m working on a data logging project using the Raspberry Pi Pico and I need to collect readings from multiple I2C sensors specifically a BME280 (for temp/humidity/pressure), an MPU6050, and an OLED display. The challenge I’m facing is occasional data collisions or missed readings, especially when trying to log data in real-time to an SD card using SPI.

Has anyone worked with a similar setup? Would using a dedicated I2C multiplexer (like TCA9548A) help, or is there a better software-level fix to handle timing issues? Also curious if CircuitPython handles this smoother than MicroPython?

Appreciate any tips or best practices from folks who’ve juggled multiple I2C devices on a Pico.

References:

https://www.theengineeringprojects.com/2022/03/introduction-to-raspberry-pi-pico.html
https://learn.adafruit.com/circuitpython-on-raspberrypi-pico
https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico

Hi @Aria291175

Welcome to the forum!

Using a multiplexer isn’t necessary unless you’re trying to run multiple sensors using the same address.

Circuitpython is a derivative of Micropython, using it really won’t make any sort of difference in terms of performance, if performance is an issue I’d recommend using C++ or C if you’re really needing to get everything possible out of an MCU.

I’d say the simplest option would be to slow things down and add a delay between readings, 0.1 second should be fine but you can experiment with it. You may also get results from slowing down the I2C bus frequency.

1 Like

The BME280 and MPU6050 may both try to communicate at the same time or you may be polling too rapidly. I think it is better to use an I2C multiplexer.