Learn/rusty_esp_arduinoarduinoesp32rust

rusty_esp_arduino Is a Pure Rust Alternative to Arduino

rusty_esp_arduino is a pure Rust alternative to Arduino for ESP32 sketches: setup, loop, wifi, camera and mic, on a laptop or on a real board.

Signed by M·
Daylight brick workbench with a brick laptop cabled by black tiles to a green ESP board, a small red-roofed brick house beside the cable, and golden threads joining the orbs above them
Is rusty_esp_arduino a pure Rust alternative to Arduino?

Yes for the sketch, no for .ino files. rusty_esp_arduino is a pure Rust alternative to Arduino setup and loop on ESP32: wifi, camera, microphone and stream verbs, and the same sketch runs on a laptop or a board. It does not compile Arduino sketches.

Related reading

Builder field note

rusty_esp_arduino: Arduino-Style setup and loop in Rust for ESP32

APIs, composition, and home deployment for rusty_esp_arduino: Arduino-Style setup and loop in Rust for ESP32 live on the field note.

rusty_esp_arduino is a pure Rust alternative to Arduino for makers who want the familiar sketch and a memory-safe language on an ESP32. You still write a setup and a loop. You still start Wi-Fi, grab a camera frame, read a microphone and push a stream. What changes is the language, the way a call reports failure, and the fact that the same sketch runs on a laptop before a board arrives in the post.

This page is the comparison. The builder field note on rusty_esp_arduino is the API record: types, the Board seam, and the hardware rows. Here the question is narrower. When is this pure Rust alternative to Arduino the right swap, and when should the sketch stay on the Arduino-ESP32 core?

What Arduino gives an ESP32 maker

Arduino is the market standard because two functions won a generation of makers: do this once, then do this forever. The Arduino-ESP32 core puts that shape on Espressif chips, and the Arduino language reference is still what most first tutorials teach.

The sketch you already know

A typical ESP32 camera or microphone sketch in Arduino is setup() and then loop(). Wi-Fi begins with a call, the camera begins with a call, and the loop grabs a frame and sends it. That shape is why Arduino remains the default in classrooms, in vendor examples, and in the first afternoon someone spends with a new board. A pure Rust alternative to Arduino that threw the shape away would be a different product. This one keeps it.

What the core asks you to accept

The Arduino-ESP32 core is C++ on top of ESP-IDF. A sketch can allocate freely, a String can reallocate, and a callback can outlive the buffer it points at. Those are ordinary C++ costs, and they are fine until a camera frame and a microphone block share a small chip. A pure Rust alternative to Arduino exists to keep the sketch and drop that class of mistake: the compiler refuses a use-after-free that a sketch would otherwise ship.

The pins, by contrast, should not live in the sketch at all. On this side of the comparison they live in a cited board record, which is what choosing an ESP32 board is sorting through: flash size, PSRAM and which chip can carry a camera, a microphone or a mesh node.

How this pure Rust alternative to Arduino is shaped

rusty_esp_arduino keeps the two-function sketch and refuses to pretend it is the Arduino core. You write Rust. .ino files are out of scope. The verbs still read like the calls you already know, and the crate itself has no C of its own.

setup, loop, and the Board seam

A sketch is two functions handed to sketch::run(setup, loop_once). Setup runs once. The loop runs forever, and the board watchdog is fed after every pass. Nothing in the sketch names a GPIO number. The facade calls the Janus packages for image, audio, video and identity through one Board trait. On the chip, that board is the firmware project espino generates, over ESP-IDF's camera, PDM microphone and Wi-Fi.

use rusty_esp_arduino::prelude::*;

fn setup() {
    wifi::begin("home", &psk);
    identity::begin(None);
    cam::begin(cam::Config::qvga_jpeg().at_fps(12));
    mic::begin(mic::Config::pcm16_16k());
    stream::listen_gated(80);
}

fn loop_once() {
    if let Some(frame) = cam::grab() {
        stream::push_jpeg(&frame);
    }
    if let Some(block) = mic::read() {
        stream::push_pcm(&block);
    }
}

Calls return false or None, and last_error() holds the reason until the next success. A pure Rust alternative to Arduino that returned Result on every line would stop looking like a sketch, so the facade stays Arduino-shaped on purpose. The field note records the real names: stream::push_jpeg and stream::push_pcm, not a single push.

The same sketch on a laptop

Install HostBoard and the sketch runs on a laptop. The camera is a colour-bar test pattern or a folder of JPEGs, and the microphone is a tone or a WAV file, paced like the real sensors. Host tests run 12 loops and receive 12 of 12 frames at 320 by 240 and 12 of 12 PCM blocks through the video package's receivers, none lost. ffmpeg decodes the page. A pure Rust alternative to Arduino can sit in CI before the parcel arrives, which a board-only Arduino loop cannot.

The laptop board does not pretend to be the chip. Its loop is paced by whichever peripheral is due last, so at 15 frames a second the camera sets the rhythm, and a microphone read once per pass under-samples the tone. A real board's I2S buffers hold audio between reads. The host says plainly that it has none.

Where Arduino still wins

A pure Rust alternative to Arduino is the wrong tool if the goal is to paste a .ino from a blog and have it compile. rusty_esp_arduino borrows the shape, not the core, not the libraries, and not the preprocessor.

Honest limits

Three limits belong in the first paragraph a searcher reads, not in a footnote.

  • Track A only. The facade targets std Rust on ESP-IDF. On bare-metal esp-hal you call the function packages directly. The esp-rs book describes both toolchains, and Rust is the language the sketch is written in.
  • There is no C in this crate. There is C underneath. ESP-IDF is Espressif's C, and every Wi-Fi radio runs Espressif's binary blob. Calling rusty_esp_arduino a pure Rust alternative to Arduino describes our sketch, not a C-free device.
  • One finding is recorded and not fixed. A generated porch camera paced by the camera forwards about 12 of the microphone's 50 audio blocks a second. The standalone microphone firmware does not have that gap.

On a Seeed XIAO ESP32-S3 Sense, the sketches espino generates on this facade held one did:mata across boots, reflashes and three foreign flashes. Video for ten minutes was 20,119 packets with one lost. The camera over the mesh was 721 packets in 60 seconds, none lost and none reordered. Those are the same rows the field note already publishes. They are measurements of this pure Rust alternative to Arduino, not a promise about every board.

Where to start

If the trade sounds right, flash with espino and follow deploy an ESP32 at home in an afternoon. The case for keeping the picture and the sound on your own LAN is a smart home without the cloud. The Flash vision and the Learn index sit beside this comparison.

The crate is dual-licensed MIT or Apache-2.0 and lives in the Remade With Rust family. It speaks the same household identity as MATA. When a board datasheet or a device log needs to become a retrieval corpus, the same house runs RAG Converter, which turns documents into embeddings you can load into a vector database.

FAQ

Quick answers for builders evaluating this technology.

Will rusty_esp_arduino compile my existing Arduino .ino file?

No. It borrows the shape of an Arduino sketch, not the Arduino-ESP32 core, the libraries, or the preprocessor. You write Rust functions named setup and loop_once. .ino compatibility is a stated non-goal.

Which Arduino calls does this pure Rust alternative cover?

The sketch verbs are wifi::begin, cam::begin and cam::grab, mic::begin and mic::read, and stream::push_jpeg and stream::push_pcm. Pins stay in the board record. A call returns false or None, and last_error() holds the reason.

Can I run the Rust sketch before the ESP32 arrives?

Yes. HostBoard runs the same sketch on a laptop. The camera is a test pattern and the microphone is a tone. Host tests push 12 frames and 12 audio blocks through the real receivers, with none lost.

Does a pure Rust alternative to Arduino remove the C under the chip?

It removes C from this crate. It does not remove C from the device. Track A firmware runs on Espressif's ESP-IDF, and the Wi-Fi radio is Espressif's binary blob. The pure Rust claim is about our sketch code, not a C-free radio.

When should I stay on the Arduino-ESP32 core?

Stay when you need a blog's .ino to compile, an Arduino library that has no Rust twin, or a classroom that teaches the Arduino language reference. Switch when you want the sketch shape, memory safety, and a laptop run of the same code.