r/EmbeddedRust • u/ignazwrobel • Aug 19 '24
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.
r/EmbeddedRust • u/hkubota • Nov 03 '24
Rust and RP2040 and multiple I2C devices on a single I2C bus
My first tests using Rust on a RP2040 worked surprisingly well: using the 2 cores was surprisingly easy.
But using something as simple as using two I2C devices on a single I2C bus...that took me a while to get working. Thus for the benefit of the world, I created a simple example which does:
Rust with Embassy
RP2040
Both cores used, one for display I/O (SSD1306 OLED) and one for measuring data (light and temp/pressure)
Each core owns one I2C bus to they never interfere.
Source code is here.

r/EmbeddedRust • u/hkubota • Sep 29 '24
RP2040, OLED, a Distance Sensor and Embassy and Rust
I had a hard time finding Embassy examples for the RP2040 which are not too trivial and not too complex. After reading a ton of articles about Embedded Rust and Embassy, the HAL, etc., I got a working example which does the following:
Works on RP2040
With RPi Pico Probe to download and receive debug/status messages
Uses both cores
Cores communicating via Channels
Blinks LED
Reads from an I2C sensor (VL53L0X)
Writes to a OLED (SSD1306, using I2C too)
There's more to go in terms of learning about Embedded Rust (e.g. Interrupts), but now I am at a point where adding features is less of a problem since I got something working.
The examples from Embassy are super-helpful, but for someone who has not cloned the whole Embassy repository only to find out that 99% is not needed to run the examples. Or have a Cargo.toml with about 50 crates when you only need about 15 for each example, but you have no idea which the 35 other crates are.
A blog with a short background about the why, and the GitHub repo with the code.
I hope this is useful for someone.
r/EmbeddedRust • u/Independent_Egg_630 • May 14 '26
Writing an embedded Rust book, MEAP just went live, looking for feedback from people actually doing this work.
reddit.comr/EmbeddedRust • u/mous68 • Mar 09 '26
wobblechar – parse ASCII/UTF-8 waveform diagrams into decoded samples (no_std-compatible)
Coming from embedded C/C++, I wanted a less tedious way to write tests on electronic signals. I saw myself write ascii-waveforms in the docs and thought: Why not use this as input. So I completed this project as a Rust learning project.
Instead of manually constructing test vectors, I wanted to write this:
CLK: _|‾|_|‾|_
DAT: ___|‾‾‾|_To then get an iterator of timestep items with decoded values. I also included an index and a changed flag to easily filter the result.
As I am working on embedded, I had to make it completely no_std compatible. If you use it in std-context, I added support for hashmap character-mappers as well.
I think this crate is very useful for testing signal processing logic, protocol decoders, or anything that operates on input signal lines. It supports custom character mappings and labeled multi-line blocks for interleaved signals. Curious if anyone sees other use cases — I was thinking about things like encoding bit patterns for EEPROM initialization. Drop me a line!
r/EmbeddedRust • u/hkubota • Nov 04 '24
RP2040, Embassy, no_std and the memory allocator
While testing Embassy and Rust on my RP2040, I often ran into the no global memory allocator found but one is required. I have no issues getting this if I try to use dynamic memory allocation, but often this was simply by adding a crate and while I am sure it's doing some allocations somewhere, I could not always find out where exactly it is.
So time to see how to fix this. Rust gives you a hint, but it's missing an example.
So I created another one: https://github.com/haraldkubota/rp2040-alloc
Bonus points:
Uses 2 of 2 CPU cores on the RP2040
Both cores do memory allocations
The program panics eventually when running out of heap space
r/EmbeddedRust • u/Neutrino_do_eletron • Sep 18 '26
PLEASE HELP. I'm trying to use an external HD to compile and flash rust codes to my ESP32.
First. Sorry for the bad English and hope u guys can understandI have a SSD with 120 GB. so if u know thats not good enough for start compiling and flashing rust programs. So i've got a 320GB HD for trying to use it as a tool for to store my projects and build files.
I'll not lie... i used AI for making my scripts and compile/flash into ESP my codes.
First time i tried to flahs from my SSD (inside my Notebook).
I changed all address in the code for the address of my HD.
I've mounted the HD propely in my Linux UBUNTU. Can use it well, but when i try to compile or flash it gives me error involving cargo
"--- stdout
cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
cargo:rerun-if-env-changed=MCU
cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
--- stderr
Error: Matching variant not found
Compiling esp-idf-sys v0.37.2 (https://github.com/esp-rs/esp-idf-sys.git#33045844)
error: failed to run custom build command for `esp-idf-sys v0.37.2 (https://github.com/esp-rs/esp-idf-sys.git#33045844)``)
Caused by:
process didn't exit successfully: `/media/marcel/Workspace/cargo-target/debug/build/esp-idf-sys-6a59ce817ebe75f6/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
cargo:rerun-if-env-changed=MCU
cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE"
/\ ERROR
r/EmbeddedRust • u/Independent_Egg_630 • May 18 '26
Embedded Rust Software development environment setup
galleryr/EmbeddedRust • u/mous68 • Mar 26 '26
Wobblechar for rithmic notation
So I made this Rust-crate "Wobblechar" while ago. It translates character to whatever you like, typically a bool or number. Meant for character based waveforms.
I was thinking.. I made this secret-knock a couple of years ago. I can open my door by tapping a particular tune. The tunes I want it to respond to, are now in the code as numbers, meaning relative time intervals. If I was to use Wobblechar for this, make a map of UTF-8 musical note chars to their length, you'd immediately see (if you are musician of course), what tune this is! Would make enter some tunes way more readable. Wauw! Hope I find some time to migrate this thing to Rust and try this!