This repository contains a collection of Rust projects for the ESP32, built using the esp-idf framework. Each project is a standalone example demonstrating different features of the ESP32 with Rust.
check_spiram: A simple utility to check if SPIRAM (PSRAM) is available and functional.wifi: A basic example of connecting the ESP32 to a Wi-Fi network.wifi_display: A project that connects to Wi-Fi and displays information on an attached ST7789 TFT screen.wifi_display_openweather: Fetches weather data from the OpenWeatherMap API and displays it on the screen.wifi_display_openweather_rtc: An extension of the weather display project that incorporates a Real-Time Clock (RTC) for timekeeping, synchronized via NTP.wifi_display_openweather_rtc_mqtt: The most advanced project, which adds MQTT publishing of weather data to the RTC weather station.
These projects are set up to be built and flashed using the esp-idf toolchain for Rust.
- Rust Toolchain for ESP32: Make sure you have the Rust compiler and the
xtensa-esp32-espidftarget installed. The recommended way to set this up is by usingespup.espup install
- ESP-IDF: The build system relies on the Espressif IoT Development Framework (ESP-IDF).
espupshould handle this installation.
Some projects require credentials for services like Wi-Fi or weather APIs.
- Copy the example secrets file:
cp secrets.toml.example secrets.toml
- Edit
secrets.tomland fill in your details, such as Wi-Fi SSID, password, your OpenWeatherMap API key, and MQTT broker details.
To compile a specific project, navigate to its directory and use cargo.
-
Build the project:
cd <project-folder> cargo build
Replace
<project-folder>with the directory of the project you want to build (e.g.,wifi). -
Flash to device: To flash the compiled program onto your ESP32 and view the output, use
cargo-espflash.cd <project-folder> cargo espflash flash --monitor
(This command flashes the device and then opens a serial monitor to display logs.)