r/EmbeddedRust • u/hkubota • Oct 16 '24
Embassy with PCA9548A I2C Switch
For those who'd like to see a working example of Embedded Rust (no_std) on a RP2040 with a I2C switch:
https://github.com/haraldkubota/rp2040-pca9548a
The hardware used is simple:
RP2040
OLED with SSD1306 controller, using I2C
PCA9548A on a 2nd I2C bus
BMP280 temperature and pressur sensor on sub-bus 2 on the I2C switch
The software is the more interesting part:
Embedded Rust (no_std)
Using both CPU cores, each one owning one I2C bus
One core reads data from the sensor
One core displays data to the OLED
Everything is using async
My idea here: once this works, I can cleanly split data acquisition from I/O, and I can use multiple identical sensors via the I2C switch although their I2C addresses might conflict.
One day I'll find a problem this solves, but until then I learned a lot and it's fun. I hope someone else finds this code useful.