Skip to content

chriamue/esp32-rust-example

Repository files navigation

esp32-rust-example

This is a simple example of how to use Rust to program an ESP32 microcontroller.

This project is based on the esp-idf-template project.

Prerequisites

See Prequisites

Add user to dialout group to access serial port:

sudo usermod -a -G dialout $USER

Install cargo espflash:

cargo install cargo-espflash

Board Information

cargo espflash board-info

outputs:

[2024-02-04T12:12:44Z INFO ] Serial port: '/dev/ttyUSB0'
[2024-02-04T12:12:44Z INFO ] Connecting...
[2024-02-04T12:12:45Z INFO ] Unable to connect, retrying with extra delay...
[2024-02-04T12:12:46Z INFO ] Using flash stub
Chip type:         esp32 (revision v1.0)
Crystal frequency: 40MHz
Flash size:        4MB
Features:          WiFi, BT, Dual Core, 240MHz, Coding Scheme None
MAC address:       24:6f:28:00:00:00

Troubleshooting

If you get an error like:

[2024-02-04T12:12:44Z INFO ] Serial port: '/dev/ttyUSB0'
[2024-02-04T12:12:44Z INFO ] Connecting...
[2024-02-04T12:12:45Z INFO ] Unable to connect, retrying with extra delay...

Try to press the boot button on the ESP32 board and run the command again.

Setup

Copy example.env to .env and adjust the settings.

Building

. $HOME/export-esp.sh
cargo build

Features

I tested on two boards:

To configure the right pins, you can use the v2 or v3 feature:

cargo build --features v2

Flashing

cargo espflash flash --release --monitor --partition-table partitions.csv

License

MIT

See also

Releases

No releases published

Packages

No packages published

Languages