ESP32 remote control for robotica in rust
APACHE-2.0 License
Copied and adapted from https://github.com/ivmarkov/rust-esp32-std-hello.
Highlights:
Todo:
Assumptions:
graph TD
Main((Main))
Mqtt((Mqtt))
Mqtt --> |event| Main
Main --> |cmd| Mqtt
Button1((Button1)) --> |event| Main
Button2((Button2)) --> |event| Main
Main --> |status| Display((Display))
Display --> Display1
Display --> Display2
button1 --> Button1
button2 --> Button2
mqtt --> |event| Mqtt
Mqtt --> |cmd| mqtt
graph TD
Main((Main))
LightController((LC))
SwitchController((SC))
LightController --> |status| Main
LightController --> |cmd| Main
Main --> |event| LightController
SwitchController --> |status| Main
SwitchController --> |cmd| Main
Main --> |event| SwitchController
esp
toolchain from the pre-built binaries: rustup default esp
esp
toolchain for the demo crate only by executing rustup override set esp
inside the rust-esp32-std-demo
directory once you have cloned the demo as per below)rustup install nightly
and then rustup default nightly
instead of installing/building the Rust & Clang ESP forks and switching to their esp
toolchain as advised above)$PATH
, Bindgen will still pick the system one
export LIBCLANG_PATH=<path to the Espressif Clang lib directory>
prior to continuing the build processcargo install ldproxy
git clone https://github.com/ivmarkov/rust-esp32-std-demo
cd rust-esp32-std-demo
export WIFI_SSID=<ssid>
export WIFI_PASS=<ssid>
--target <target>
flag to all cargo build
lines below.cargo build
or cargo build --release
cargo install espflash
espflash /dev/ttyUSB0 target/[xtensa-esp32-espidf|xtensa-esp32s2-espidf|riscv32imc-esp-espidf]/debug/rust-esp32-std-demo
dev/ttyUSB0
above with the USB port where you've connected the boardNOTE: The above commands do use espflash
and NOT cargo espflash
, even though both can be installed via Cargo. cargo espflash
is essentially espflash
but it has some extra superpowers, like the capability to build the project before flashing, or to generate an ESP32 .BIN file from the built .ELF image.
espflash
at least once, or else you might not have a valid bootloader and partition table!pip install esptool
esptool.py --chip [esp32|esp32s2|esp32c3] elf2image target/xtensa-esp32-espidf/debug/rust-esp32-std-demo
esptool.py --chip [esp32|esp32s2|esp32c3] -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x10000 target/xtensa-esp32-espidf/debug/rust-esp32-std-demo.bin
espmonitor /dev/ttyUSB0
(you need to cargo install espmonitor
first)cargo pio espidf monitor /dev/ttyUSB0
(you need to cargo install cargo-pio
first)
rust-esp32-std-demo
project directory, or else the built ELF file will not be detected, and the stack traces will not be decoded!screen /dev/ttyUSB0 115200
(use Ctrl+A
and then type :quit
to stop it)miniterm --raw /dev/ttyUSB0 115200