/ser-no-std

Simplified Embedded Rust: ESP Core Edition Book Projects and Templates

Primary LanguageRust

Simplified Embedded Rust: ESP Core Library Edition - Book Repository 🦀

BookCover

Welcome to the Simplified Embedded Rust: ESP Core Library Edition book repository. Here you will find all the book related resources. You can get a copy of the book here.

📝 Reporting Issues & Content Suggestions

If you find any text errors, typos, or formatting issues in the book, please report a text error here so that it can be addressed in a later revision.

If you find any code issues in the book, please report a bug here so that it can be addressed in a later revision.

You are also welcome to suggest a feature here so it may be considered for content in the future.

🔗 Links to Book Examples

Device Devkit GitHub Links Wokwi Links
ESP32-C3 ESP32-C3-DevKitM-1 ESP32-C3-DevKitM-1 Branch CH 6 - GPIO
Blinky
Button Controlled Blinking
Button Press Counter
CH 7 - ADC
Simple Voltmeter
Temperature Sensing
CH 8 - Timers & Counters
Timer Based Delay
Real-Time Timer
CH 9 - PWM
LED Fading
CH 10 - Serial Communication
Console Printing
Interacting with an I2C RTC
CH 11 - The Embassy Framework
Blinky
Real-time Timer
LED Cycling
UART Echo
ESP32-C3 ESP32-C3-DevKit-RUST-1 🚫 🚫
ESP32-S2 ESP32-S2-DevKitM-1 🚫 🚫
ESP32-S3 ESP32-S3-DevKitC-1 🚫 🚫
ESP32 ESP32-Dev-KitC 🚫 🚫

🔌 Wiring Templates for End of Chapter Questions

These are pre-wired templates to get you started with end of chapter questions. Questions that are not included would use exisiting book examples as templates. If you notice a template missing or would like to request one, feel free to submit a feature request.

Device Dev Kit CH 5
GPIO
CH 6
ADCs
CH7
Timers & Counters
CH8
PWM
CH9
Serial Comms
CH10
Embassy
ESP32-C3 ESP32-C3-DevKitM-1 Q5
Q6
Q7 & Q8
Q4
Q5
Q6 & Q7
Q1 Q4
Q5
Q6
Q7
🤷‍♂️ Q6
ESP32-C3 ESP32-C3-DevKit-RUST-1 🚫 🚫 🚫 🚫 🚫 🚫
ESP32-S2 ESP32-S2-DevKitM-1 🚫 🚫 🚫 🚫 🚫 🚫
ESP32-S3 ESP32-S3-DevKitC-1 🚫 🚫 🚫 🚫 🚫 🚫
ESP32 ESP32-Dev-KitC 🚫 🚫 🚫 🚫 🚫 🚫

🧑‍💻 Development Options

1. 🌐 Wokwi Web Interface (Recommended)

This is the recommended option for beginners as it is the quickest and easiest way to get started. Each code example has a corresponding project on Wokwi, allowing you to run and modify the code directly from your web browser. Links to the examples are provided in the earlier section.

2. 🌐🛠️ Wokwi Web Interface with Hardware

If you prefer to work with physical hardware, Wokwi provides an approach to flash an external development board/device directly from the web interface. To do that you need to press F1 in the Wokwi code window to access the command palette. Afterward, you can select the "Flash Firmware to Device" option.

3. 🏡🛠️ Local Editor with Physical Hardware

If you prefer to develop locally with physical hardware, you can clone the examples locally and set them up to run on an external development board. The software required entails installing the nightly toolchain with the rust src component, modifying the target for cross-compiling in addition to installing flashing tools to download code to the external hardware. This includes the following

a) Install Rust 🦀:

If you do not have Rust installed already, follow the instructions on the rustup website.

b) Install the Nightly Toolchain with the rust-src Component:

Run the following command in a terminal window:

rustup toolchain install nightly --component rust-src

c) Set the target:

Run the following command in a terminal window:

rustup target add riscv32imc -unknown -none -elf

d) Install espflash:

Run the following command in a terminal window:

cargo install espflash

Afterward, the easiest way to flash an ELF binary, is to add espflash as your Cargo runner. This way, when enterning cargo run, the code would automaitcally perform the flashing after file generation. This is done by adding the following line to your .cargo/config.toml file:

[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))']
runner = "espflash flash --monitor"

e) Install cargo-generate:

When creating your own projects from scratch, it is highly recommended that you use cargo-generate. Through cargo-generate you can create new project templates pre-configured for any ESP device. Click on the link below for instructions to install and use cargo-generate. To install cargo-generate run the following command:

cargo install cargo-generate

Afterward, to generate a no-std template run the following command:

cargo generate esp-rs/esp-template

4. 🏡🔮 Local Editor with Wokwi

If you prefer to develop locally with Wowki (no hardware), you can clone the examples locally and install the following extensions for the simulator:

Afterward, you need to also configure your project for Wokwi using these instructions.

⚠️ Local development with Wokwi still requires the same setup as local editor with physical hardware since you will be compiling locally, however, flashing tools are not required since external hardware is not involved. Also through cargo-generate you can generate projects pre-configured for Wokwi skipping the second part after extension installation.

⛔️ Important Note:

Options 2, 3, and 4 are not recommended for beginners due to the added complexity and, in some cases, required installations.

🧱 Hardware Component List (Optional)

This is a list of the components used in the different examples in the book. Acquiring these components is OPTIONAL and recommended only after you are comfortable with the material. You will only need these components if you are interested in doing physical hardware development at a later time (options 2 and 3 listed in the development options section earlier).

Component Documenation Purchase Links
Development Board (Choose one) ESP32-C3-DevKitM-1
ESP32-C3-DevKit-RUST-1
ESP32-C3-DevKitM-1 (AliExpress)
ESP32-C3-DevKit-RUST-1 (AliExpress)
Female to Male Wires N/A AliExpress
Prototyping Breadboard N/A AliExpress
LEDs Datasheet AliExpress
LED Bar Datasheet AliExpress
Push Button Datasheet AliExpress
Potentiometer Datasheet AliExpress
NTC Temperature Sensor Datasheet AliExpress
DS1307 Datasheet AliExpress