ambientsensor-rs
This is a rust re-implementation of an embedded C project I did a while ago: AmbientSensor.
Schematics, photos, ect. will be in that repository, this repository is just for the rust firmware.
Status
This is still a work in progress.
- The OPT3002 luminosity sensor is not implemented.
- The panic handler needs to get hooked up to the EEPROM to store error logs then reset.
Purpose
Co-workers kept hyping up this new rust language, and I wanted to see if the hype was warranted.
On paper rust seems amazing, but the only way to really evaluate a language is to use it. I specifically wanted to compare embedded rust to embedded C, and AmbientSensor was simply the last embedded project I completed in C.
Turns out, the hype was warranted.
There is not a lot of commentary I can offer about embedded rust that has not already been said. The concepts rust introduces (safety, ownership, lifetimes) make developing robust code simple. The language is new and still has a small (but rapidly growing) ecosystem for embedded development. From my experience a lot of embedded development is still C simply because nothing else offers a compelling reason to switch (except C++ depending on who you ask). The features rust brings to the table are incredibly compelling for embedded development, and I think rust has a bright future in this industry.
Notable crates used
- rtic – RTOS
- rtt_target – Probe based logging
- cargo-embed – build and run your code with one command
- embedded-hal – abstractions for embedded hardware
Crates Developed
- eeprom25aa02e48 – EEPROM driver, my first rust crate
- w5500-ll – Low level W5500 Ethernet chip driver
- w5500-hl – Higher level W5500 Ethernet chip driver
- w5500-dhcp – Simple W5500 DHCP client
- bme280-multibus – Bosch BME280 driver
- newam-mqtt – MQTT packet serialization and deserialization
Building
You will need rustup and the thumbv6m-none-eabi
target.
rustup target add thumbv6m-none-eabi
After you have that target available you can build, the default target is already set in .cargo/config.toml
.
cargo build
COMMENTS