A Sensor application for ESP32-C3 written in Rust using esp-rs/esp-idf-sys and the Espressif IDF SDK
----------------------------------------------
MAINTAINANCE MODE FOR ESP32 SENSOR APPLICATION
----------------------------------------------
The ESP32 Sensor is currently only maintained but its functionality will not be
extended to support tests for the latest versions of the SUSEE application protocol.
For tests on ESP32 devices, the streams-poc-lib test application is the recommended application.
The ESP32 Sensor crate is maintained to facilitate the software development process of ESP32 platform specific code (contained in the sensor-lib) using cargo build utils.
This Sensor application can be build and flashed to ESP32-C3 platforms using tools developed and provided by the esp-rs community. Its main purpose is to test Rust code used for the streams-poc-lib without the limitations of a foreign function interface.
To build the ESP32 Sensor application for ESP32 platforms (currently only ESP32-C3 provided), you need the following:
- If you want to flash the Sensor app on an ESP32-C3 device you need to install the Espressif software development environment.
This is not needed if you only want to build the ESP32 Sensor app into an ELF file that can be flashed later on.
The Rust based build process for the ESP32 Sensor app uses its own copy of the needed Espressif tools that is
automatically downloaded.
To install the Espressif software development environment please follow the instructions given in the Prerequisites section of the Streams POC library. - Make sure your installed python3 version is >= 3.8 and pip is already installed
(
sudo apt install python3-pip
). - Check that your rustc version is >= 1.58.0 (see Rust install hints in the main README).
- Use the stock nightly Rust compiler:
rustup install nightly
rustup default nightly
# For future daily/weekly updates
rustup update
- We also need rust-src to install cargo-espflash in one of the next steps
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- Install clang version >= 12
sudo apt-get update
sudo apt-get install clang-12 --install-suggests
- Install Cargo-Espflash
sudo apt-get install libudev-dev
sudo apt-get install pkg-config
cargo install cargo-espflash
cargo install espflash
- Install ldproxy
cargo install ldproxy
The fundamentals of these build Prerequisites are taken from the Rust on ESP32 STD demo app project by Ivan Markov. If you want to build the ESP32 Sensor for other ESP32 devices than ESP32-C3 you can try to follow the instructions there to build for Extensa core based MCUs (ESP32-C3 is a Risc-V core based MCU).
All build steps must be executed in the main folder of this project (where this README is located):
Before building we need to specify the WiFi SSID, the WiFi password and the url of the used IOTA Bridge as environment variables. These variables will be hard coded into the ESP32 Sensor. Currently this is the only way to initiate a socket connection to the ESP32. This also means that currently you need to compile the ESP32 Sensor app yourself to test it:
export SENSOR_MAIN_POC_WIFI_SSID="Susee Demo"
export SENSOR_MAIN_POC_WIFI_PASS=susee-rocks
export SENSOR_MAIN_POC_IOTA_BRIDGE_URL="http://192.168.0.100:50000"
If you have no ESP32-C3 device you can just start the build using cargo-espflash. The ELF file will be created in the project folder.
cargo espflash save-image ESP32-C3 sensor-esp-rs.elf --release
If you have an ESP32-C3 device you can plug in the usb (or other serial bus) cable of your board
and start the build (with or without --release
):
cargo espflash --monitor --partition-table="partitions.csv" --release
Given you already installed all needed drivers to access the serial port of your board, the port will be
detected automatically by cargo-espflash. After the application has been build and flashed the log output
of the ESP32 Sensor app is displayed on the console. This is controlled by the --monitor
option used above.
The CLI documentation can be found in the Sensor README