Welcome to the Simplified Embedded Rust: ESP Standard Library Edition book repository. Here you will find all the resources related to the book. You can get a copy of the book here.
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.
This is a list of the project links containing the example source code for the different ESP devkits. All projects were set up using VS Code as an editor. Each branch contains the same collection of code examples accommodated for the various ESP devkits supported by Wokwi. Click on the link for the device you desire to work with and clone that particular branch.
Device | Devkit | GitHub Links |
---|---|---|
ESP32-C3 | ESP32-C3-DevKitM-1 | ESP32-C3-DevKitM-1 Branch |
ESP32-C3 | ESP32-C3-DevKit-RUST-1 | ESP32-C3-RUST-1 Branch |
ESP32-S2 | ESP32-S2-DevKitM-1 | ESP32-S2-DevKitM-1 Branch |
ESP32-S3 | ESP32-S3-DevKitC-1 | ESP32-S3-DevKitC-1 Branch |
ESP32 | ESP32-Dev-KitC | ESP32-DevKitC Branch |
This is a list of links to the Wokwi examples presented in each chapter. These are based on the ESP32-C3 device and would need to be rewired for other devices. The Wokwi setup for the different devices can be also extracted from the VSCode projects. If you notice a template missing or would like to request one, feel free to submit a feature request.
Chapter | Example Link |
---|---|
CH 5 - GPIO | Blinky LED Bar Blinking Button Press Counter |
CH 6 - ADC | Simple Voltmeter Temperature Sensing |
CH 7 - Timers & Counters | Pulse Duration Monitor Real-Time Timer |
CH 8 - PWM | LED Fading |
CH 9 - Serial Communication | UART XOR Cipher Interacting with an I2C RTC |
CH 10 - IoT and Networking | Connecting to WiFi Simple HTTP Client Simple HTTP Server Syncronizing System Time |
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. These are based on the ESP32-C3 device and would need to be rewired for other devices. If you notice a template missing or would like to request one, feel free to submit a feature request.
Chapter | Question Links |
---|---|
CH 5 - GPIO | Q5 Q6 Q8 & Q9 |
CH 6 - ADC | Q4 Q5 Q6 & Q7 |
CH 7 - Timers & Counters | Q2 |
CH 8 - PWM | Q3 Q4 Q5 Q6 |
CH 9 - Serial Communication | ๐คทโโ๏ธ |
CH 10 - IoT and Networking | ๐คทโโ๏ธ |
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.
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.
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 the ESP-IDF framework in addition to flashing tools to download code to the external hardware. The following links include the instructions for installing the ESP-IDF framework and flashing the development board.
If you do not have Rust installed already, follow the instructions on the rustup website.
Run the following command in a terminal window:
cargo install espup
Run the following command in a terminal window:
espup install
d) Install Python.
e) Install git.
Run the following command in a terminal window:
cargo install ldproxy
espup
will create an export file that contains some environment variables required to build projects. If youโre on Windows, thereโs no need to do anything special. However, for Unix-based systems, the file is $HOME/export-esp.sh
. You can add the environment variables to your shell profile directly by adding the content of $HOME/export-esp.sh
to your shellโs profile:
cat $HOME/export-esp.sh >> [path to profile]
For example, if you are using the zshrc
profile your command may look something like this:
cat $HOME/export-esp.sh >> ~/.zshrc
Afterward, its recommended that you restart your terminal session for changes to take effect.
std
development. Refer to Step 1 under the following link.
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"
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 std
template run the following command:
cargo generate esp-rs/esp-idf-template cargo
If you prefer to develop locally with Wowki (no hardware), you can clone the examples locally and install the following extensions for the simulator:
cargo-generate
you can generate projects pre-configured for Wokwi skipping the second part after extension installation.
Options 2, 3, and 4 are not recommended for beginners due to the added complexity and, in some cases, required installations. For example, installing the ESP-IDF framework in particular is quite involved and not necessarily always a smooth experience.
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 |