espup
esp-idf-template
espup | esp-idf-template | |
---|---|---|
7 | 14 | |
200 | 338 | |
4.0% | 4.1% | |
8.6 | 8.6 | |
11 days ago | 18 days ago | |
Rust | CMake | |
Apache License 2.0 | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
espup
-
Rust Based Linux Process Manager with both a TUI and a GUI
https://github.com/esp-rs/espup/issues/19 https://github.com/tauri-apps/tauri/issues/1355
-
Switching from C++ to Rust
Thanks for mentioning it. I already tried using it a few months ago and brushed it off as still being a WIP, but it still didn't work when I tried again just a few days ago. Asking in the Matrix chat when first trying it sadly only got me a "works for me" from the developers.
What Espressif is doing with their esp-idf and porting it to Rust is promising, but overall it still needs work. Using the toolchain to develop on the ESP32 was at least slightly painful half a year ago before they introduced espup[1], having to keep a patched LLVM around etc., and supposedly support for their Xtensa architecture is coming to LLVM soon[2] so this will improve in the future.
I'd also love to see Bluetooth support in esp-idf-svc[3], but they seem to be lacking people with the required knowledge to design and implement an abstraction for it[4].
[1]: https://github.com/esp-rs/espup
-
Embedded Rust tutorials on the ESP32-C3
The environment setup can now be done with espup, its a Rust tool that replaces the bash scripts and also works in Windows.
- ESP32 Buyer’s Guide: Different Chips, Firmware, Sensors
-
How do I program an ESP32 S3 in Rust using podman from WSL?
Installing it locally should be relatively simple with espup, let me know if you finally decide to go for this option and have some questions!
-
Rust for Embedded Development (e.g. microcontrollers)
We even have our own installer (written in Rust of course :D) - https://github.com/esp-rs/espup
esp-idf-template
- Mabez Rust on Espressif chips – update
-
Edge IoT with Rust on ESP: MQTT Subscriber
use anyhow; use embedded_svc::mqtt::client::Event; use embedded_svc::mqtt::client::QoS; use embedded_svc::wifi::{AuthMethod, ClientConfiguration, Configuration}; use esp_idf_hal::peripherals::Peripherals; use esp_idf_svc::eventloop::EspSystemEventLoop; use esp_idf_svc::mqtt::client::{EspMqttClient, MqttClientConfiguration}; use esp_idf_svc::nvs::EspDefaultNvsPartition; use esp_idf_svc::wifi::{BlockingWifi, EspWifi}; use std::{thread::sleep, time::Duration}; fn main() -> anyhow::Result<()> { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches(); let peripherals = Peripherals::take().unwrap(); let sysloop = EspSystemEventLoop::take()?; let nvs = EspDefaultNvsPartition::take()?; let mut wifi = BlockingWifi::wrap( EspWifi::new(peripherals.modem, sysloop.clone(), Some(nvs))?, sysloop, )?; wifi.set_configuration(&Configuration::Client(ClientConfiguration { ssid: "SSID".into(), bssid: None, auth_method: AuthMethod::None, password: "PASSWORD".into(), channel: None, }))?; // Start Wifi wifi.start()?; // Connect Wifi wifi.connect()?; // Wait until the network interface is up wifi.wait_netif_up()?; // Print Out Wifi Connection Configuration while !wifi.is_connected().unwrap() { // Get and print connection configuration let config = wifi.get_configuration().unwrap(); println!("Waiting for station {:?}", config); } println!("Wifi Connected"); // Set up handle for MQTT Config let mqtt_config = MqttClientConfiguration::default(); // Create Client Instance and Define Behaviour on Event let mut client = EspMqttClient::new( "mqtt://broker.mqttdashboard.com", &mqtt_config, move |message_event| { match message_event.as_ref().unwrap() { Event::Connected(_) => println!("Connected"), Event::Subscribed(id) => println!("Subscribed to {} id", id), Event::Received(msg) => { if msg.data() != [] { println!("Recieved {}", std::str::from_utf8(msg.data()).unwrap()) } } _ => println!("{:?}", message_event.as_ref().unwrap()), }; }, )?; // Subscribe to MQTT Topic client.subscribe("testtopic/1", QoS::AtLeastOnce)?; loop { // Keep waking up device to avoid watchdog reset sleep(Duration::from_millis(1000)); } }
-
Edge IoT with Rust on ESP: NTP
use anyhow; use chrono::{DateTime, Utc}; use embedded_svc::wifi::{AuthMethod, ClientConfiguration, Configuration}; use esp_idf_hal::delay::FreeRtos; use esp_idf_hal::peripherals::Peripherals; use esp_idf_svc::eventloop::EspSystemEventLoop; use esp_idf_svc::nvs::EspDefaultNvsPartition; use esp_idf_svc::sntp::{EspSntp, SyncStatus}; use esp_idf_svc::wifi::{BlockingWifi, EspWifi}; use std::time::SystemTime; fn main() -> anyhow::Result<()> { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches(); let peripherals = Peripherals::take().unwrap(); let sysloop = EspSystemEventLoop::take()?; let nvs = EspDefaultNvsPartition::take()?; let mut wifi = BlockingWifi::wrap( EspWifi::new(peripherals.modem, sysloop.clone(), Some(nvs))?, sysloop, )?; wifi.set_configuration(&Configuration::Client(ClientConfiguration { ssid: "Wokwi-GUEST".into(), bssid: None, auth_method: AuthMethod::None, password: "".into(), channel: None, }))?; // Start Wifi wifi.start()?; // Connect Wifi wifi.connect()?; // Wait until the network interface is up wifi.wait_netif_up()?; // Print Out Wifi Connection Configuration while !wifi.is_connected().unwrap() { // Get and print connection configuration let config = wifi.get_configuration().unwrap(); println!("Waiting for station {:?}", config); } println!("Wifi Connected"); // Create Handle and Configure SNTP let ntp = EspSntp::new_default().unwrap(); // Synchronize NTP println!("Synchronizing with NTP Server"); while ntp.get_sync_status() != SyncStatus::Completed {} println!("Time Sync Completed"); loop { // Obtain System Time let st_now = SystemTime::now(); // Convert to UTC Time let dt_now_utc: DateTime = st_now.clone().into(); // Format Time String let formatted = format!("{}", dt_now_utc.format("%d/%m/%Y %H:%M:%S")); // Print Time println!("{}", formatted); // Delay FreeRtos::delay_ms(1000); } }
-
ESP32 Standard Library Embedded Rust: GPIO Interrupts
use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use esp_idf_hal::gpio::*; use esp_idf_hal::peripherals::Peripherals; use esp_idf_sys::{self as _}; static FLAG: AtomicBool = AtomicBool::new(false); fn gpio_int_callback() { // Assert FLAG indicating a press button happened FLAG.store(true, Ordering::Relaxed); } fn main() -> ! { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches(); // Take Peripherals let dp = Peripherals::take().unwrap(); // Configure button pin as input let mut button = PinDriver::input(dp.pins.gpio0).unwrap(); // Configure button pin with internal pull up button.set_pull(Pull::Up).unwrap(); // Configure button pin to detect interrupts on a positive edge button.set_interrupt_type(InterruptType::PosEdge).unwrap(); // Attach the ISR to the button interrupt unsafe { button.subscribe(gpio_int_callback).unwrap() } // Enable interrupts button.enable_interrupt().unwrap(); // Set up a variable that keeps track of press button count let mut count = 0_u32; loop { // Check if global flag is asserted if FLAG.load(Ordering::Relaxed) { // Reset global flag FLAG.store(false, Ordering::Relaxed); // Update Press count and print count = count.wrapping_add(1); println!("Press Count {}", count); } } }
-
ESP32 Standard Library Embedded Rust: GPIO Control
use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported use esp_idf_hal::delay::FreeRtos; use esp_idf_hal::gpio::*; use esp_idf_hal::peripherals::Peripherals; fn main() { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches(); // Take Peripherals let dp = Peripherals::take().unwrap(); // Configure all LED pins to digital outputs let mut led1 = PinDriver::output(dp.pins.gpio1).unwrap(); let mut led2 = PinDriver::output(dp.pins.gpio10).unwrap(); let mut led3 = PinDriver::output(dp.pins.gpio19).unwrap(); let mut led4 = PinDriver::output(dp.pins.gpio18).unwrap(); let mut led5 = PinDriver::output(dp.pins.gpio4).unwrap(); let mut led6 = PinDriver::output(dp.pins.gpio5).unwrap(); let mut led7 = PinDriver::output(dp.pins.gpio6).unwrap(); let mut led8 = PinDriver::output(dp.pins.gpio7).unwrap(); let mut led9 = PinDriver::output(dp.pins.gpio8).unwrap(); let mut led10 = PinDriver::output(dp.pins.gpio9).unwrap(); // Configure Button pin to input with Pull Up let mut button = PinDriver::input(dp.pins.gpio3).unwrap(); button.set_pull(Pull::Up).unwrap(); // Initialize variable with starting delay let mut blinkdelay = 200_u32; loop { // Algo: // Starting with first LED in sequence // 1. Turn on LED // 2. Retrieve adjusted delay based on button press // 3. Delay with adjusted value // 4. Turn off LED // 5. Delay for 100ms (to make sure LED is turned off) // 6. Repeat steps 1-5 for next LED in sequence // 7. Once all LEDs are done loop back to first LED in sequence // LED 1 led1.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led1.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 2 led2.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led2.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 3 led3.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led3.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 4 led4.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led4.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 5 led5.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led5.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 6 led6.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led6.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 7 led7.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led7.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 8 led8.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led8.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 9 led9.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led9.set_low().unwrap(); FreeRtos::delay_ms(100_u32); // LED 10 led10.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led10.set_low().unwrap(); FreeRtos::delay_ms(100_u32); } } fn button_pressed(but: &PinDriver<'_, Gpio3, Input>, del: &u32) -> u32 { // Check if Button has been pressed // If not pressed, return the delay value unchanged if but.is_low() { // if the value of the delay passed is less of equal to 50 then reset it to initial value // else subtract 50 from the passed delay println!("Button Pressed!"); if del <= &50_u32 { return 200_u32; } else { return del - 50_u32; } } else { return *del; } }
-
Embedded Rust on ESP32: compatibility issue with esp_idf_hal and embedded_hal?
fn main() -> anyhow::Result<()> { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches(); println!("Hello, world!");
-
Rust on Esp32
There is a template for how to use Rust from an idf.py cmake project where you can incrementally add Rust to your project by calling to from C. Instructions for it are at https://github.com/esp-rs/esp-idf-template/blob/master/README-cmake.md
-
ESP32 example project
Sorry for the poor way of supporting you, I am currently at the embedded world and I can't try much to reproduce your issue. I just merged: https://github.com/esp-rs/esp-idf-template/pull/84. Which can be what you were facing, can you use the latest template and see if the issue still persists? Let me know how it goes
-
Embedded Rust on ESP32C3 Board, a Hands-on Quickstart Guide
The awesome ESP IDF Template will save us the pain of configuring a fully functional project ourselves, use it like so:
-
Accessing embedded peripherals from state machine
fn main() { // It is necessary to call this function once. Otherwise some patches to the runtime // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 esp_idf_sys::link_patches();
What are some alternatives?
esp-idf-template - Template application for https://github.com/espressif/esp-idf
rust-esp32-std-demo - Rust on ESP32 STD demo app. A demo STD binary crate for the ESP32[XX] and ESP-IDF, which connects to WiFi, Ethernet, drives a small HTTP server and draws on a LED screen.
bluetooth-proxies - This repo hosts known, tested devices that can serve as Bluetooth proxies for Home Assistant.
esp-template - A minimal esp-hal application template for use with cargo-generate
esp-web-flash-server - Starts a local server serving a web page to flash a given ELF file
avr-hal-template - cargo-generate template for avr-hal projects
esp-wifi - A WiFi, Bluetooth and ESP-NOW driver for use with Espressif chips and bare-metal Rust
template - Template for a generic rust project hosted on GitHub
esp-idf-hal - embedded-hal implementation for Rust on ESP32 and ESP-IDF
std-training - Embedded Rust on Espressif training material.
esp32-camera
templates - Templates for bootstrapping a Rust TUI application with Ratatui