2025-05-23: Course correction on the ESP32

Posted on May 23, 2025 by Magnus Nordlander

As I’ve mentioned in other channels (Discord, Instagram) there’s been a lot of progress with the Dev Rig these past weeks. I can now actually pull shots on it, and they taste good.

While the direction forward is clear - get the dev rig to where I can use it as a daily driver so that I can work on the Bianca - I’ve been considering next steps. My thinking is to get started on the ESP32-C6 firmware.

Thus far everything has been running on the RP2350, and that makes sense, since that will be in control of the machine in general, but that also means I’m restricted to configuration either in code or using the buttons and encoder on the machine.

The solution to this lies in the ESP32-C6, since that’s responsible for WiFi, BT and Zigbee/Thread, and as such that’s where my focus has been these past few days.

I’ve written previously about the different approaches to using Rust on the ESP32 family. There’s esp-idf-hal, which is basically a Rust interface to the C based esp-idf, and esp-rs which is a pure Rust implementation. I’ve also written about the state of rustc (the compiler) for ESP32. In short; if you’re on ESP32 or ESP32-S3, you can’t use the mainline toolchain, due to them using the esoteric Xtensa architecture. Luckily, the ESP32-C6 uses a RISCV architecture which is well supported in the mainline toolchain.

My plan has been to use esp-rs, but having experimenting with it, and especially esp-wifi, the corresponding crate for using the WiFi peripheral, I’ve reconsidered. Put simply, at the moment, esp-wifi simply doesn’t work as well as using the IDF based HAL. More specifically, it doesn’t matter if I use async or blocking, socket accepts take seconds when in STA mode and everything is just really slow. On the contrary, when using the IDF, I haven’t been having any issues.

Long-term I would prefer to use esp-rs, because that allows for a larger amount of code sharing between the RP2350 firmware and the ESP32-C6 firmware, but at the moment, it looks like I’m going with esp-idf-hal.

On the ESP32 side, things have been productive as well. For a lot of my projects, I’ve been using ESPHome as the ESP32 firmware. ESPHome is an amazing piece of software. For an incredible range of applications, it allows you to set up an ESP32 device with little to no code, with an almost perfect Home Assistant integration. However, when you do want to write a lot of code yourself, basing a firmware off ESPHome is less than ideal, especially if you want to write your firmware in Rust.

So, I looked around for an ESPHome server library. I didn’t find any (just client libraries), so I decided to write my own, and thus was born esphome-device-rs. At the time of writing, it’s by no means ready, but I have a working proof-of-concept (running on the Gravity of all things), and I’m pretty happy with the structure. Hopefully I should have the Dev Rig hooked up to Home Assistant in a couple of weeks!