
A browser button can switch the LED on the ESP32-C6-DevKit-C1 through a Rust Wi-Fi server. The Rusty Bits shows you how this development board handles web requests while a separate task takes care of LED updates. The server uses picoserve to deliver its page, while Embassy provides the network stack and communication between tasks. Follow along as the Rust project takes shape, from supplying network credentials and obtaining an IP address to passing button presses from the web page to the hardware.
ESP32-C6-DevKit-C1: A Rust Wi-Fi Server
TL;DR Key Takeaways :
- The ESP32-C6-DevKit-C1 has a 2.4 GHz Wi-Fi 6 radio, a built-in LED and two USB-C ports.
- The project uses station mode so a smartphone on the same network can send requests to toggle the LED.
- Espressif supplies precompiled Wi-Fi libraries with a C API, and esp-radio provides a safe Rust interface over most of them.
- Embassy’s network stack uses DHCP for an IPv4 address, and most setups need at least three sockets for the application, DHCP and DNS.
- The picoserve server uses a 2 KB HTTP buffer and signals a separate task to toggle the WS2812 LED.
The ESP32-C6-DevKit-C1 combines an Espressif 32-bit microcontroller with a WROOM module, a 2.4 GHz Wi-Fi 6 radio, a built-in smart LED and two USB-C ports. ESP32 modules typically have a trace antenna and an RF shield for Wi-Fi. Before a Rust application can serve a web page, its Wi-Fi software needs both low-level radio support and a network stack.
The board can join a local network as a station, act as an access point or communicate directly with another ESP32 using an Espressif peer-to-peer protocol. This project uses station mode, with a smartphone on the same network sending requests to toggle the LED.
Set Up the Rust Project and Radio
Use rustup to obtain the Rust compiler, Cargo and the target for the ESP32-C6, then create the project with esp-generate. The Rusty Bits recommends the generator over setting up the project by hand. Select esp-alloc, Embassy, esp-rtos and esp-radio for the allocator, concurrency and Wi-Fi support.
Espressif developers and the community maintain the esp-hal project crates, including esp-radio, and the project also uses debugging tools and an editor plugin. Most of the board’s hardware abstraction layer remains unstable, and some GPIOs are off limits on the module. The project uses GPIO 8 for the LED; its default heap uses the 64 kilobytes reclaimed from the second-stage bootloader.
Espressif’s Wi-Fi peripheral registers are not currently documented, and the company does not provide open source drivers for them. Instead, it supplies precompiled binaries with a C API for initialization, configuration and events. The esp-radio crate provides a safe Rust interface over most of those libraries; Rust’s foreign function interface and tools such as bindgen can also work with C.
Low-level Wi-Fi code needs resources for timing-sensitive operations, including task creation, event queues and memory allocation. Wi-Fi initialization requires function pointers for those resource operations. Traits in esp-radio-rtos-driver define that interface, so developers can choose compatible implementations; esp-rtos and esp-alloc meet the requirements for this project.
Here is a selection of other guides from our extensive library of content you may find of interest on ESP32 boards and projects.
- Build a $20 Desk Buddy with an ESP32 C6 Microcontroller
- Which ESP32 Should You Choose? Variants and Features 2026 Guide
- How to Choose the Right ESP32 Chip for Your Next Project
- 10 Weekend IoT Projects to Build with ESP8266 and ESP32
Connect the Board to the Local Network
After initialization, esp-rtos starts its scheduler and an Embassy main task for async Rust code. On the single-core ESP32-C6, the async runtime and RTOS provide interfaces for concurrency. The default Wi-Fi configuration is not enough for this server: configure the board as a station using the network’s SSID and password.
The project supplies those credentials through compile-time environment variables, making the build fail if they are missing. Dummy values can satisfy the language server during editing, although The Rusty Bits cautions that hard-coding real credentials into firmware probably is not appropriate for production.
Create another Embassy task to manage the Wi-Fi controller alongside the rest of the async network code. It attempts to connect to the access point, waits for a disconnect after a successful connection and pauses briefly before trying again.
Run the Embassy Network Stack
The generated project includes embassy-net, the default async embedded Rust networking crate developed by the Embassy community. It handles network functions such as addressing and routing and supports reliable or timely communication. Its new function returns a network stack and runner using the esp-radio Wi-Fi interface, an IP configuration, stack resources and a random seed.
Configure DHCP to obtain a dynamic IPv4 address from the gateway. The stack resources hold the assigned address, socket metadata and other state; their const generic sets the maximum socket count. Most setups need at least three sockets: one each for the application, DHCP and DNS lookups.
A 64-bit random seed is also required. The board’s hardware abstraction layer produces 32-bit random values, so the project uses shifting to meet that requirement. Spawn a separate Embassy task for the runner, which handles Wi-Fi events and updates the stack’s internal state.
Embassy’s attribute macro generates task types at compile time and places them in static memory; an async function’s arguments become part of its generated task type. Embassy task arguments must have static lifetimes, but the runner holds a reference to mutable stack resources. Direct access to mutable statics is not allowed in safe Rust.
StaticCell, from the static_cell crate, addresses that by wrapping the resources for static declaration, then initializing them at runtime and returning a mutable reference with a static lifetime. The application can then wait for its IP address and print it to the terminal.
Serve the Page With picoserve
picoserve is designed to work with Embassy, and The Rusty Bits recommends it as a fast route to an async bare-metal Rust web server. Embassy itself compiles on stable Rust, although some Embassy examples may still need nightly.
Define the application with a router and add a route for each endpoint, using a routing style familiar to Axum users. A GET request to the root serves an HTML file, while a POST to the toggle endpoint handles the button press, with the toggle route accepting an async function or closure. The page’s form sends that POST; its CSS centers and enlarges the button, adds a press transition and includes a workaround for the animation in mobile Safari.
The project uses picoserve’s default configuration, a 2 KB HTTP buffer and one open server socket in the main task on the standard HTTP port. It also needs TCP receive and transmit buffers; embassy-net examples commonly size them at around 1,500 bytes. The server’s async function does not return, so it occupies the end of the main task.
Send Button Presses to the LED Task
The board’s WS2812 LED uses the ESP32’s remote control transceiver peripheral for high-speed signaling. The project uses the async interface with RmtSmartLeds and the Smart LEDs crate, configuring one LED with RGB8 color and GRB color order. The LED has eight bits per color, and its buffer size can be calculated with a const function.
Compared with earlier versions, RmtSmartLeds requires an additional argument and generic parameters, adding complexity in exchange for supporting devices beyond the WS2812. The buffer size is a const generic, and the buffer-size function requires a color type. The RMT and other ESP32 peripherals have static lifetimes.
Bring in SmartLedsWriteAsync, retain the LED’s state and choose the colors to switch between. Request handlers are not supposed to mutate state; toggling directly would require interior mutability for both the LED and its state. Instead, the project uses an Embassy signal and a separate task: the server signals, and the task waits for that signal before toggling the LED.
Embassy Sync also provides channels; a signal holds one value, or no value in this case. This separation is expected to let the server respond promptly, because it is unclear how long the LED write will take. A type alias hides the longer LED type signature passed to the task.
In our view, the most telling part is how much glue sits between the radio and a web page: an RTOS, an allocator, an async runtime and a network stack. Rust makes each seam explicit, which is a real strength for anyone who wants to understand it. Before copying this, we would check that every crate version you pull in matches the ones the video uses. The changed RmtSmartLeds arguments and generic parameters show why that version check matters. In our view, embedded Rust libraries that depend on each other can break builds when versions drift apart.
The key is to keep hardware work separate from the browser’s request, since the LED write time is unclear. You can build on that separation to explore how async Rust connects a web interface to a physical device. If you want hands-on experience with embedded networking, the ESP32-C6-DevKit-C1 Rust Wi-Fi server is a project well worth trying.
Media Credit: The Rusty Bits
Disclosure: Some of our articles include affiliate links. If you buy something through one of these links, Geeky Gadgets may earn an affiliate commission. Learn about our Disclosure Policy.