/esp32-c3-32s-kit-example

A simple Rust example for the ESP-C3-32S-Kit ESP32 WiFi+Bluetooth Development Board with ESP32C3 chip from Ai-Thinker

Primary LanguageRustMIT LicenseMIT

Rust on ESP-C3-32S-Kit board

A simple Rust example for the ESP-C3-32S-Kit ESP32 WiFi+Bluetooth Development Board with ESP32C3 chip from Ai-Thinker. This example uses the std implementation.

Highlights:

  • No external periphery needed, just the board
  • Small but not just an empty "hello world" example
  • Available custom bootloader and partition tables for this board
  • Preconfigured runner, just call cargo run

This example is still work in progress! Current open tasks:

  • Example builds and turns on both the amber and white built-in leds and the RGB led. It also has some basic polling of the built-in button
  • Usage of built-in button to change the mode (Working solution exists, not yet happy with it)
  • Control of built-in RGB LED using PWM (It works but dependencies are not yet 100% clean)

Motivation and goals

This is my simple example to learn Rust beginning with the board Ai-Thinker ESP-C3-32S-Kit board. It uses the built-in periphery (LEDs and button) to demonstrate basic concepts to get started with. It is not my intention to cover all the functionality of the board, like WiFi, SPI communication, etc. For that I recommend you to look at the esp32-std-demo linked in Credits and acknowledgment.

Preparation

  • Install the nightly toolchain of Rust: rustup toolchain install nightly
  • Make sure the toolchains are up to date: rustup update
  • Switch to nightly: rustup override set nightly
  • Install ldproxy: cargo install ldproxy
  • Install espflash and espmonitor crates: cargo install espflash espmonitor

Build & run

To build the project (this step is optional)

cargo build

To build, flash and monitor the output (all in one step thanks to preconfigured runner, be aware that it assumes that you are using /dev/ttyUSB0):

cargo run

If you need more control or other parameters, you can use the espflash and espmonitor commands instead (see the Credits and acknowledgment for more details on how to do this).

Credits and acknowledgment

For this example I used the template in https://github.com/esp-rs/esp-idf-template to create the initial files. Furthermore this exmaple is heavily inspired by:

You can check those for better instructions on how to use espflash and espmonitor and other details I don't cover here. I also would like to thanks the people in #esp-rs:matrix.org, especially @sirhcel for his contribution to make the PWM signals for the RGB led work.

Disclaimers

  • I am a beginner at Rust and ESP32 boards. Don't take my implementation as best practice! I don't really understand every single line of code of my example, which I have partly copied from the template and other examples.
  • Still, I am very grateful if you have comments or improvement proposals. Don't hesitate to open issues!
  • I have tested this example using my own board. This might not work well with other ESP32C3 boards. Use this at your own risk.
  • I believe that you don't need to install ESP_IDF as well (see https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html), but I am not very sure about this yet.

License

Copyright (c) 2022 javiser esp32-c3-32s-kit-example is distributed under the terms of the MIT License.

See the LICENSE for license details.