r/esp32 • • 1h ago

I made a thing! I Ran My 30M Parameter Model locally on an ESP32 at 1.12 Tokens/s (8 MB Flash, 8 MB PSRAM)

Post image
51 Upvotes

I’ve been building this project for a few months. It started because I kept hearing that running a language model on an ESP32 was impossible (like literally impossible???)

I didn’t like the sound of that, so this is what I decided to do with several months of my life 😂

I ended up with a 30M parameter model that runs offline on a XIAO ESP32-S3. It generates 1.12 tokens/s using the board’s flash and PSRAM.

Dataset: I used FineWeb-Edu and TinyStories for general text, and SODA, OASST1, UltraChat, and smol-smoltalk for dialogue.

Tokenizer: SentencePiece BPE with a vocabulary of 6,144 tokens.

Architecture: I wanted to try different architectures just out of curiosity. I also wanted to understand why people use GQA in language models in the first place so I chose Transformer GQA, Shared Transformer, GRU, GRU with Local Attention, Mamba-1, RWKV-7, Gated DeltaNet, and Causal TCN. I gave all 8 the same small amount of training data (10M tokens) to see which one would do best.

I tried tests like these:

  1. Predicting the next token in text the model hadn’t seen before
  2. Picking which sentence sounds right or which answer makes sense in context
  3. Answering everyday reasoning questions
  4. Looking up a number or remembering two facts
  5. Seeing how well each model did with 20 seconds to train

Transformer GQA did best overall, so I ended up sticking with it. I checked how my model was doing at 50M, 100M, 200M, and 300M tokens. (By my estimate, getting to 300M tokens took about seven and a half hours on my computer). At that point, I went with that checkpoint and focused on making the replies better.

After I shared the project online for the first time , I got a lot of useful comments. So I decided to improve replies and get the model to run faster.

What helped to improve quality of my model's replies:

  1. I gave it more examples of the kinds of replies I wanted it to give.
  2. I gave it good and bad answers to the same question and trained it to prefer the better one.
  3. I went through the mistakes it kept making and gave it more practice on those, using the same chat format it sees on the device.

What helped to improve speed:

  1. I processed several input tokens together so the board could reuse the weights it had just read.
  2. I used INT8 SIMD so the chip could do several calculations at once when scoring the next token.
  3. The biggest change was compressing some weights to 3 bits so they’d fit in PSRAM. That let the board generate the whole reply using flash and PSRAM, with the microSD card used at startup.

With the same prompts on the same board, generation went from 0.76 to 1.12 tokens/s.

For a 30M model I thought the replies were pretty good! It could get what I was talking about, give a relevant answer and stop on its own. Here are some examples:

Me: - i baked a cake!

AI: - That sounds delicious.

Me: - my paper kite finally stayed in the air!

AI: - That sounds amazing.

Me: - my paper kite tore before it got off the ground.

AI: That sounds hard.

I don’t work in this field, so I’m not sure how companies approach projects like this. This was just a personal project I did out of curiosity and for fun! For some reason, I learn best by trying things myself and I’m sure I’ve made a few mistakes along the way 😅

GitHub code, model files, and setup guide
Training, speed improvements, and the live touchscreen demo
My first PocketGPT build


r/esp32 • • 8h ago

I made a thing! Update: I made a wrist-synth! (get the firmware and mod it)

51 Upvotes

Hallo r/esp32, I went to Synthfarm, a residency program for people who are interested in, or play/build music synthesizers, and I built this using the Waveshare ESP32S3 AMOLED (I posted this two days ago, but the firmware wasn't on github yet)

Firmware (GPL3): https://github.com/layogtima/spacecrud

Demo it in your browser: https://spacecrud.layogtima.com

What it does: record up to 60 seconds with the watch’s mics, and it splits into four screens to play around with sounds/audio recorded

Why this board: has two mics (ES7210), a DAC, amp and speaker (ES8311 + NS4150B), accelerometer, touch AMOLED, and 8 MB of PSRAM for the tape

How it’s built

  • PlatformIO + Arduino-ESP32, Arduino_GFX for the panel (art is from a WIP space game)
  • 32 kHz audio, one 64-sample block every 2 ms
  • Core 1 only makes sound; core 0 does touch, tilt and the screen rendering
  • The engine is plain C++, so the same code runs on the watch, in tests and in the browser (as an 80 KB WebAssembly file; used Claude Code for these bits)

What didn't/doesn't work well

  • speaker sometimes rattles below about 170 Hz
  • it's still tricky to use unless you get used to it
  • repetitive sounds work poorly compared to a varied sound sample

Built with lots of help from friends at Synthfarm.

If you have this board, and flash it - I would love to know how it works out for you!


r/esp32 • • 12h ago

I made a thing! Halo — A Modern, Open-Source Desk Lamp for Your Cozy Moments

Thumbnail
gallery
68 Upvotes

A little light can make a workspace feel different.

Halo is a compact, rechargeable RGB desk lamp designed to bring ambient lighting and a touch of colour to your everyday spaces.

Built around the Waveshare ESP32-C3 Mini, Halo combines custom 3D-printed mechanical components, an ultra-slim RGB LED strip and a rechargeable power system in a minimal, circular design.

Inside the Design

Mechanical & 3D Printing

  • Custom enclosure designed from scratch in Autodesk Fusion 360
  • Four-part enclosure assembly
  • 3D-printed housing and structural components
  • Circular diffuser designed for smooth, uniform illumination

Embedded & Lighting

  • Waveshare ESP32-C3 Mini as the central controller
  • Ultra-slim 2.7 mm Waveshare RGB LED strip
  • Custom Arduino firmware using FastLED
  • Automatic ROYGBIV colour cycling with five-second intervals

Power & Portability

  • Rechargeable 18650 Li-ion battery
  • USB Type-C charging
  • Compact, cable-free design

Designed to Be Built

Halo is a complete, documented maker project. The repository includes the firmware, Fusion 360 CAD files, STL models, circuit diagrams and build resources.

The idea is simple: create a thoughtfully designed desk lamp that anyone can build, customize and make their own.

Whether it's on your desk, bedside table or shelf, Halo adds a little colour to your everyday moments.

Explore the Project

I'd love to hear your thoughts on the design, enclosure, lighting and possible improvements.


r/esp32 • • 8h ago

I made a thing! a tiny webserver on an ESP-01

Post image
23 Upvotes

https://github.com/codewitch-honey-crisis/clubhouse_www

I wanted to make the smallest little webserver I could so I chose an ESP-01, which is ESP8266, not ESP32 based. It has 80KB of RAM, and 1MB of flash running at 80MHz, wifi only in terms of radio.

I utilized the arduino framework due to issues with the native RTOS support on the ESP8266 under PlatformIO

I have several bits of tooling involved in making the project work.

ClASP is used to embed a React site into a C header for delivery over a waiting socket.

htcw_buffers is used to generate serdes code for the struct sent over the websocket.

I used my gfx_web to create the headers for the font and icons.

In terms of libraries, I am using my htcw_gfx library for the display.

The main hassle was fitting everything into flash, and figuring out a way to deliver ClASP content without the ESP-IDF. I had never done it from Arduino before.

The thing is ClASP expects a waiting socket to send data out on, and it handles the HTTP headers, encoding, etc.

With the ESP-IDF you can get a socket handle off of a web request and take over the handling yourself.

With Arduino I had to write a remedial webserver and websocket mechanism by hand. Fortunately it wasn't too bad, but figuring out I had to do it in the first place took more time than I care to admit.


r/esp32 • • 6h ago

Board Review ESP32S3-Plus arrived today

9 Upvotes

The EDP32-S3-Plus has just arrived and I’m looking forward to trying it out. The Plus means I have lots of PSRAM to use for audio announcements, at least I hope so. It’s going to be the uC element of my e-paper Lantern status monitor, all battery powered of course and BLE communications between the lanterns and monitor.


r/esp32 • • 5h ago

I made a thing! php-esp32-sdk 2.0: the upstream PHP interpreter on ESP32-S3/P4, now on ESP-IDF v6.1.1

Thumbnail
php-baremetal.com
6 Upvotes

php-baremetal runs the real Zend engine (PHP 8.3 to 8.6) cross-compiled on top of ESP-IDF. PHP's memory lives in PSRAM, so the targets are the ESP32-S3 and ESP32-P4 with PSRAM (2 to 32 MB). Chips without PSRAM aren't supported.

2.0 is a rewrite. What might interest this sub:

  • ESP-IDF v6.1.1 (was v5.5.5), installed by the CLI.
  • ESP32-S3 tuning, set in the SDK: CPU at 240 MHz instead of the 160 MHz default, a 32 KB instruction cache instead of 16 KB, and an 8 KB main-task stack instead of 32 KB (it uses about 1 KB, and the 24 KB go back to internal RAM for Wi-Fi). Boards can also move Wi-Fi/lwIP/mbedTLS buffers to PSRAM and tune the static buffer count, which is what lets Wi-Fi start next to a double-buffered 1024x600 RGB panel. QIO flash where the board supports it.
  • Boards are JSON files (chip, PSRAM, flash, and peripheral blocks for display, I2C, touch, LED, microSD…). Drivers read the blocks, so Ws2812::onboard() already knows the LED pin. A project can override a block or add one, for example an SPI microSD slot on a generic S3 module, and every pin is checked before anything compiles.
  • Pin names: the new Arduino Nano ESP32 and Seeed Studio XIAO ESP32-S3 board files expose D13, A3, LED_BUILTIN to PHP as Pin::LED_BUILTIN. Waveshare, Freenove and Espressif DevKitC boards are supported too.
  • Slate: a retained-mode scene graph that composes only the bands that changed. A still screen costs zero frames.
  • Fixes measured on hardware:

    • Uninitialised PSRAM chunk headers caused zend_mm_heap corrupted on up to 20 of 20 cold starts of a large app. Now 0 of 20.
    • On the P4, core 1 polled the scheduler with no pause and could stall core 0 before app_main. One image faulted on all 102 starts; with the fix, none.
    • A closure-cache patch leaked about 49 B per bind(). Now 9M rounds run with flat memory.

bash

composer global require php-baremetal/phpbm php-baremetal/conductor
phpbm sdk:install esp32 && phpbm init blink
phpbm toolchain:install && phpbm flash && phpbm monitor

Write-up with diagrams: https://www.php-baremetal.com/blog/php-esp32-sdk-2-composer-firmware

Custom composer Registry : https://repository.php-baremetal.com/ with all available package

web simulator, built on Velxio: https://sim.php-baremetal.com/

Github: https://github.com/php-baremetal/php-esp32-sdk

It's an independent, MIT-licensed project, not affiliated with Espressif. If you have an S3 or P4 board that isn't covered, a board file is a small JSON. Which boards should we add next?


r/esp32 • • 7h ago

I made a thing! Cheap Echo clone repurposed into ESP32 Music Assistant Audiobook reader..

6 Upvotes

Cannibalised a cheap Aliexpress Echo clone, ripped out the insides, retaining the speaker and the button board which I was able to re-purpose.. Now a nice little bedside ESP32 for reading audiobooks from Music assistant with led effects..

Teardown, schematic and yaml on github https://github.com/dm2912/esp32_media_speaker/

(note the schematic has an 18 led ring, but i went with 8, for the sole reason, the 8 led arrived in the post first.. as it turns out, it was more than adequate)

needs more hotglue :D (everything is soldered, the glue was just to avoid breaks when cramming it in the case)


r/esp32 • • 1d ago

I made a thing! New to ESP32s and already amazed by what they can do.

Post image
233 Upvotes

Hey Reddit! I’m 15, and since my summer break, I’ve been developing an experimental blockchain for innovation and learning purposes. The blockchain itself isn't really the main topic here, so I’ll try to keep things simple. A blockchain can be an open network that anyone can join (what we call a P2P network—though a blockchain isn't necessarily a P2P network, and a P2P network isn't necessarily a blockchain, you get the idea...). The issue is that when a P2P network is just starting out, you usually need to find peers to connect to, so I decided to make this easier by building a bootstrap node. It's basically a participant in the network that acts as a meeting point.

Sorry for the pretty long post that doesn't necessarily fit this sub, I just wanted to share this because I’m amazed that a tiny circuit board costing under 10 euros can become the central point of a network and act as a sort of server.

Thanks for reading, and feel free to ask if you have any questions or recommendations!


r/esp32 • • 5h ago

Software help needed no serial data received error

3 Upvotes

for context i have been working on a couple projects over the last couple weeks using some esp32s3 i ordered, so far i have had no issues with them up until last night, when i suddenly started getting this error of "no serial data received"

so far among the things i have tried:

-pressing and holding the boot button during uploads

-holding boot and pressing rst during uploads

-different cable for upload

-updated drivers for my boards

-uploading with no wiring attached

-using a different device to attempt an upload

-using those websites that check for activity on the board (same error appears)

-restarting PC

What's most confusing to me is that this just happened randomly, I had literally uploaded something 2 mins earlier and all of a sudden this error appeared, even on boards that i know work because their projects are still functioning, another thing is i opened some of my sealed esp boards and they uploaded just fine, both the fake and real ones so i am utterly confused as to what to do because i don't wanna throw away perfectly good esp boards so as a last effort I'm asking if u guys could please help me out!


r/esp32 • • 8h ago

I made a thing! ESP-NOW long-range mode as a bike-to-bike voice relay for a motorcycle group intercom (open source, ESP-IDF)

5 Upvotes

I'm building Vroo, an open-source group intercom for motorcycle riders. The phones do the audio work (Opus, encryption), and an optional ESP32 box on each bike carries voice where there's no mobile signal.

How the box is designed:

  • it runs a Wi-Fi access point for its rider's phone, and talks to the other bikes' boxes with ESP-NOW in long-range mode
  • it's a deliberately simple relay: it never has the group key, so it can't decrypt anything. It reads a small plain routing header, filters by group, drops duplicates and passes packets on
  • firmware in C on ESP-IDF 5.x, with the packet logic in a component that has host-run tests, sharing test vectors with the app

Where it is: phone to box works on my desk (an iPhone and an Android phone talking through one box, 10–30 ms round trip). Box to box is the next step, and I'd love advice from anyone who has used ESP-NOW long range outdoors:

  • realistic range between two moving bikes, and antenna placement (I'm planning on ESP32-WROOM-32U boards with external antennas)
  • how many 20 ms voice streams fit at the long-range rate once packets are relayed over a few hops
  • running the soft AP and ESP-NOW together on one radio

Repo (GPL-3.0): https://github.com/shubhanjanmedhi/vroo


r/esp32 • • 13h ago

I made a thing! Streaming 5 GHz camera video with an ESP32-P4 screen and ESP32-C5

12 Upvotes

With 55 neighbor routers crowding 2.4 GHz around my desk (~76% channel load), I wanted my DIY Home Assistant hallway camera off 2.4 GHz instead of building around another ESP32-S3 camera board. Espressif's ESP32-C5 brings 5 GHz Wi-Fi 6, though it has no camera interface or display bus of its own. Meanwhile, the 8-inch ESP32-P4 camera touchscreen I bought had the MIPI-CSI camera pipeline, MIPI-DSI display, and hardware JPEG encoder I needed, except its internal companion radio was a 2.4 GHz-only ESP32-C6. Holding that onboard C6 in reset at boot let me wire a small ESP32-C5 onto its three-wire UART so the P4 handles video and UI while the C5 handles 5 GHz Wi-Fi.

Both chips run ESP-IDF 5.5. I looked at esp-hosted and PPP network tunneling first, then dropped both because Wi-Fi retries over a three-wire UART with no RTS/CTS flow control can stall the pipe; sending framed JPEGs into a custom ESPHome component on the C5 kept failure modes simple and gave me native Home Assistant discovery without maintaining a separate MQTT or RTSP stack. On the P4 side, Espressif's esp_video V4L2 stack and hardware jpeg_encode driver made more sense than porting older DVP-focused esp32-camera code or burning CPU on software JPEG, squeezing 320x240 frames into ~6 KB in about 3 ms while LVGL 9.3 drives the 8-inch UI and live charts at 15 fps.

My first fresh P4 build went straight into a boot loop, which is how I learned ESP32-P4 boards in the wild span early silicon and newer v3.0 steppings that need separate sdkconfig targets. Once it booted and I spent a few late nights going back and forth with AI on the glue code, two link quirks showed up at 2 Mbaud. Without hardware flow control, a sharp, text-heavy scene could swell past the C5's 16 KB UART buffer or block the UI thread, so the P4 drops frames non-blockingly when the wire is busy and re-compresses oversized frames harder on the fly. A normal dual-band Wi-Fi scan on the single-radio C5 also parked the radio off-channel long enough to freeze the live feed, so I interleaved 130 ms passive listens on one channel with 140 ms windows back on Channel 153 to flush queued frames. That scanner picked up 68 physical radios on 5 GHz vs 55 on 2.4 GHz around my desk, which looked like a bug in my math until the per-channel view showed only 8 of them sharing Channel 153 with me.

Plotting P4 serial output right above C5 Wi-Fi output on the screen also made wireless retries easy to spot, while keeping Wi-Fi video traffic at zero whenever nobody has Home Assistant open. The camera is still aimed at my office ceiling while I put off designing a rear mount for the C5, with source code, prebuilt images for both P4 revisions, and build notes on GitHub:

https://github.com/limengdu/xiao-esp32c5-labs/tree/main/D2-HA-5GHz-Sensor


r/esp32 • • 9h ago

I made a thing! Flappy Bird-inspired game on ESP32-WROOM-32 with ST7735S display (ESP-IDF)

4 Upvotes

Flappy Bird-inspired game on ESP32-WROOM-32 with ST7735S display (ESP-IDF)

Hello r/esp32!

I'd like to share a small embedded project I've been working on: a Flappy Bird-inspired game running on a real ESP32-WROOM-32 development board.

The game runs on a 1.8-inch ST7735S TFT display (128×160, used in landscape orientation at 160×128).

Why this ESP32 board?

I used the ESP32-WROOM-32 because I already had this development board available. It provided sufficient processing power, memory, and GPIO pins for the game and the ST7735S display.

Hardware

  • ESP32-WROOM-32 development board
  • ST7735S 1.8-inch TFT display
  • SPI interface
  • Built-in BOOT button (GPIO 0) for game control

Software

  • ESP-IDF 5.5
  • C++
  • LovyanGFX 1.2.33

I chose LovyanGFX after comparing several graphics libraries. I wanted a flexible graphics library with support for the ST7735S display and the features needed for this project.

A technical challenge

One of the biggest challenges was getting the ST7735S display working correctly. I had to work through the display configuration to achieve proper colors and reliable operation.

Features

  • Real-time gameplay with a 30 FPS target
  • One-button control using the BOOT button
  • High score saved in ESP32 NVS, so it persists after reboot
  • Custom pixel-art graphics
  • Landscape display orientation

The project includes the complete source code and build instructions. LovyanGFX is included as a Git submodule.

Demo

Here's a short video showing the game running on the actual hardware:

https://youtu.be/kLJ0nbKsZMo

Source code

https://github.com/vladislav1975/FlappyBird

I'd appreciate feedback, especially from people experienced with ESP-IDF, display programming, or ESP32 game development.

I'm interested in hearing what you think about the implementation and what you might approach differently.

Thanks for taking a look!


r/esp32 • • 15h ago

Software help needed ESP32-P4 Native USB (OTG/TinyUSB) Not Enumerating on Windows

6 Upvotes

Hi everyone,

I'm working on a computer vision project using an ESP32-P4-Pico-M board and a Raspberry Pi Camera Module v2 (OV5647). I need to transfer captured image data from the ESP32-P4 to a Windows PC over the board's native USB port.

I'm currently trying to get native USB device communication working in Arduino IDE, but the USB device does not enumerate on Windows.

Hardware

  • Board: Waveshare / Spotpear ESP32-P4-Pico-M
  • MCU: ESP32-P4, silicon revision v1.3
  • PSRAM: 32 MB
  • Flash: 32 MB
  • Native USB: P1 4-pin connector (USBD_N, USBD_P, GND, VCC_5V)
  • Programming/debug: Separate onboard CH343 USB-UART bridge, connected to COM6
  • Host: Windows PC

The P1 native USB connector is separate from the CH343 programming/debug port. I am using COM6 to upload firmware and monitor logs, while P1 is intended for native USB communication with the PC.

Software

  • Arduino IDE
  • ESP32 board package by Espressif Systems: 3.3.11
  • Board selected: ESP32P4 Dev Module
  • Upload mode: UART0 / Hardware CDC
  • USB mode: USB-OTG (TinyUSB)
  • USB CDC On Boot: Disabled
  • Chip Variant: Before v3.00
  • Flash size: 32 MB
  • PSRAM: Enabled

What I have already verified

Previously, I used ESP-IDF 6.1 on this same board and successfully:

  • Booted the ESP32-P4.
  • Initialized and tested the 32 MB PSRAM.
  • Detected the OV5647 camera.
  • Initialized the camera through esp_video.
  • Captured an 800 × 800 RGB565 image.
  • Verified that the captured image data changes between frames.

I also confirmed from the board schematic that P1 is the native USB connector and is separate from the CH343 USB-UART interface.

I previously attempted native USB using ESP-IDF/TinyUSB, but P1 did not enumerate on Windows. I switched to Arduino IDE to try a simpler USB device test.

Current problem

I located the Espressif USB library's USBSerial example directly in the installed Arduino package and compiled/uploaded it through COM6.

The upload completed successfully. However, the native USB connection on P1 still does not appear to enumerate as a USB CDC device on Windows.

I also tried the Arduino IDE's USB Keyboard example, but it failed to compile because it uses the generic Arduino Keyboard library and cannot find HID.h:

C:\Users\parth\AppData\Local\Arduino15\libraries\Keyboard\src/Keyboard.h:25:10:
fatal error: HID.h: No such file or directory

This appears to be the generic Arduino Keyboard example rather than an ESP32-P4-specific native USB example.

After flashing the USBSerial sketch, the programming UART showed the following boot output:

ESP-ROM:esp32p4-eco2-20240710
Build:Jul 10 2024
rst:0x1 (POWERON),boot:0x20f (SPI_FAST_FLASH_BOOT)
SPI mode:DIO, clock div:1
load:0x4ff33ce0,len:0x1174
load:0x4ff29ed0,len:0xd08
load:0x4ff2cbd0,len:0x3518
entry 0x4ff29ed0
E (113) esp_core_dump_flash: Incorrect size of core dump image: -2061056978

The output stops there. I am not currently trying to debug the core-dump warning; my immediate goal is to get native USB device enumeration working.

What I need help with

  1. Has anyone successfully used the ESP32-P4-Pico-M native USB P1 connector as a USB device with Arduino-ESP32?
  2. Is USB-OTG (TinyUSB) the correct Arduino Tools setting for native USB device mode on the ESP32-P4?
  3. Are there known issues with native USB CDC enumeration on Arduino-ESP32 3.3.11, especially on ESP32-P4 revision v1.3?
  4. Is there a minimal, known-working Arduino sketch for the ESP32-P4 that enumerates as USB CDC or another USB device class through the native USB connector?
  5. Are there any specific board-level requirements for enabling the native USB peripheral on this board that are not covered by the Arduino ESP32P4 Dev Module configuration?

I would appreciate advice from anyone who has successfully used native USB on this board or a similar ESP32-P4 board.

Thanks!


r/esp32 • • 1d ago

I made a thing! I built my own AI Desktop Assistant using ESP32-S3 and Gemini

Post image
63 Upvotes

The project combines an ESP32-S3 N16R8, an ST7735 TFT display, an INMP441 microphone, and a MAX98357A audio amplifier with a speaker.

The system communicates with a Python server running on my PC, which connects to Google’s Gemini API to handle AI interactions.

Current features:

• Voice interaction

• AI-powered responses using Gemini

• TFT display interface

• Wi-Fi connectivity

• PC-hosted Python backend

My goal was to build a compact desktop assistant that combines embedded electronics with cloud-based AI.

This is still a work in progress, and I’m planning to improve its capabilities further.


r/esp32 • • 1d ago

I made a thing! I made a STICKMAN DECATHLON on esp32 s31 mosacio

23 Upvotes

A decathlon-style game where the board is the controller: shake to sprint, tilt in rhythm to swim/cycle/paddle, punch to throw. Ten events, hot-seat multiplayer, replays, ghosts, OTA updates and an optional online leaderboard. Video above, source at the bottom.

## Why the ESP32-S31 / ESP-Mosaico

Honestly, I picked the board before the chip: the Mosaico has everything a handheld game needs in one package: a 480×480 AMOLED, an IMU, audio, a vibration motor, a battery with a fuel gauge, and USB. But the S31 turned out to matter:

- **32 MB of PSRAM** is what makes replays and ghosts possible. Every event records per-frame state snapshots and replays them through its own renderer.
- **Enough CPU to software-render the whole screen at 40 fps** (everything is drawn in code, no sprite sheets apart from a few kayak sprites), with time left for audio synthesis.
- **16 MB of flash** fits two 3 MB OTA slots plus a separate NVS partition for the leaderboard cache.
- **Wi-Fi** for the leaderboard sync and OTA, but it's only switched on during a sync to save the 65 mAh battery.

## Libraries, and why

- **ESP-IDF 6.1 (plain C), not Arduino.** I needed direct control over DMA, the partition table, OTA with bootloader rollback and the USB stack. Most of the hard problems below would have been hidden (or unfixable) behind Arduino's abstractions.
- **No LVGL, my own strip renderer.** LVGL is great for widget UIs, but a game redraws the whole screen every frame. I render 48-row strips into two DMA buffers (one being drawn while the other goes out to the panel), so I never need a full framebuffer in the hot path.
- **TinyUSB CDC (through the board's USB console component)** for the serial port, plus a small protocol of my own to stream screenshots to a Python script. That's why the screenshots are pixel-perfect.
- **No MIDI player on the device.** A Python script converts national anthem MIDI files into melody + bass tables at build time, and a tiny software synth plays them. Much smaller and more predictable than parsing MIDI at runtime.
- **ESP Web Tools + esptool-js** so people can install it from the browser without installing ESP-IDF.
- **Cloudflare Workers + D1** for the leaderboard: no server to maintain, and the free tier covers a hobby project. Syncs are signed per board and sanity-checked server-side.

## Hurdles and edge cases

- **The serial port wasn't what I thought it was.** I assumed the game's COM port was the S31's built-in USB-Serial/JTAG. It's actually a TinyUSB CDC device on the USB-OTG HS controller. The USJ driver installed fine and received... nothing. On top of that, writing binary data through stdout got corrupted, because the console VFS translates line endings. The fix was talking to the TinyUSB CDC API directly, and muting logs while a screenshot is streaming.
- **Two COM ports.** The running game and download mode enumerate as different ports, and toggling RTS resets the chip. My flash script has to reset into download mode, wait for the other port to appear, then flash.
- **The fuel gauge lies for this battery.** The BQ27220's state of charge is way off for a 65 mAh cell, so the battery percentage comes from voltage instead.
- **Gestures you can't actually do.** My first discus had you physically spin the board. It was impossible and a bit dangerous. Flicking the board while steering a ball was too hard as well. The controls that work best turned out to be rhythm tilting and rolling a ball around the screen with tilt.
- **You can't watch the screen while shaking it.** Every action needed an eyes-free cue (a sound plus a vibration pattern), otherwise the 100 m was just guessing.
- **Keeping saves across updates.** NVS stays fixed at 0x9000 so OTA updates never touch records or athletes. Boards flashed before I changed the partition layout needed one web flash to move over.
- **Real-world Wi-Fi.** Testing on a phone/PC hotspot that gave no usable DNS, so the board falls back to public DNS servers.

## Known limitations

- It only runs on the Mosaico. Porting means swapping the board layer (display, IMU, audio).
- Gesture thresholds are tuned mostly on me, so I'd like to hear how they feel in other hands.
- The leaderboard has sanity checks but isn't cheat-proof.

Feedback welcome, especially on the gesture detection and the renderer.

Source: https://github.com/1verysimple-lab/stickman-decathlon
Flash from the browser: https://1verysimple-lab.github.io/stickman-decathlon/


r/esp32 • • 1d ago

I made a thing! I Built an Offline Dictation Device with ESP32-S3 (for my AI and second brain) | PocketOS

Thumbnail
youtube.com
16 Upvotes

My first post here, I am building a little device that will act as my main entry point for AI and second brain with voice dictaction by default - there are many challenges but recently a paper on oido really surprised me so I had to try it

Code not included for the moment as this is still in totally more than beta - I will post updates on the YT channel as the thing goes

But for the more curious I suggest this Oído: Open-Vocabulary Speech Recognition on a $5 ESP32-S3


r/esp32 • • 1d ago

I made a thing! Custom wake word & Keyword spotting on esp32-s3

40 Upvotes

- New custom keywords can be added without any training. Just retrieve the encoding from the web console and paste it in your code. Up to 15 keywords can be used in parallel.

- CPU: It uses 45% of one of the cores at 240 MHz and 63% at 160 MHz. During silence, CPU consumption will be close to zero.

- Memory: Very low RAM usage (15 KB) without any heap allocation. 300 kB of Flash, which can be optionally moved to PSRAM for slightly better performance.

- 8 languages are supported (English, Spanish, German, French, Italian, Chinese, Japanese, Portuguese). Each has its own library build.

- License is MIT for the demo and Apache 2.0 for the engine (TinyKW).

the demo: https://github.com/alexpg05/esp32-s3-keyword-spotting
the library: https://github.com/alexpg05/tinykw

Happy to provide support for other chips or listen to specific requests.


r/esp32 • • 1d ago

Advertisement I built LaunchGuard, an ESP32 weather display for RC flying and model rocketry

69 Upvotes

I kept checking Windy and my phone's weather app before going flying, then mentally putting the wind, gusts and cloud conditions together to decide whether it was worth heading out. I wanted a dedicated device that made those checks easier to read, so I built LaunchGuard.

The video shows the side button stepping through +2, +4, +6 and +8-hour forecasts, then switching between RC aircraft and model rocketry modes with a longer press.

The hardware is an ESP32, a 3.5-inch ST7796 SPI TFT, three separate status LEDs and one physical button in a 3D-printed enclosure, powered over USB. The firmware uses the Arduino framework and TFT_eSPI. Weather comes over Wi-Fi from a backend using Open-Meteo for a selected US ZIP code; the enclosure doesn't contain local weather sensors.

A couple of firmware details: hourly forecasts are cached on the ESP32, so stepping through them doesn't trigger a new HTTP request. Button input is sampled in a separate FreeRTOS task and passed through a queue so quick taps can still be captured during blocking network requests. Tap, mode-switch and setup actions are separated by press duration.

The display shows wind, gusts, rain chance and cloud cover, with GO / CAUTION / NO-GO indicators based on adjustable limits for the selected mode. It's a planning aid; local conditions still need checking before flying or launching.

I'd be interested in feedback on the single-button interface, and I'm happy to answer questions about the build.

Disclosure: I make and sell these. My Etsy listing is https://www.etsy.com/listing/4623677466/launchguard-wi-fi-weather-display-for-rc

AI assisted with the wording of this post; the device and demo footage are mine.


r/esp32 • • 1d ago

I made a thing! Made an ESP32 tachometer & telemetry logger for my Mercedes-Benz W123 250

Thumbnail
gallery
22 Upvotes

Hey everyone,

Since my Mercedes-Benz W123 250 (inline-six) doesn't have a factory tachometer and I wanted accurate, real-time RPM numbers while tuning my carburetor, I built a cheap digital tachometer and 10 Hz USB telemetry logger using an ESP32-C3 Super Mini, a 4N35 optocoupler, and an HT16K33 4-digit 7-segment display.

Here is the engineering breakdown behind the build:

1. Why I selected the ESP32-C3 Super Mini I went with the ESP32 platform because I was already comfortable with its hardware interrupts and micros() timing from a previous project where I built a custom wind vane angle sensor. As for the ESP32-C3 Super Mini specifically, it was just one I had laying around in my parts bin. And its microsecond timer accuracy was more than enough for pulse capture and I2C display output without needing Wi-Fi or Bluetooth overhead.

2. Which libraries I used and why

  • HT16K33 by Rob Tillaart: I chose this over the standard Adafruit LED Backpack library because of its simplicity and zero external dependencies (no Adafruit_GFX bloat). I only needed to push numbers, dashes, and a blinking colon to a 4-digit 7-segment display, and I was already familiar with Rob Tillaart's libraries so it was an easy pick.
  • Everything else (falling-edge hardware ISR, signal filtering, I2C, and CSV streaming) is written directly on top of the standard Espressif Arduino core.

3. Technical hurdles & hardware/software edge cases

  • 12V inductive noise vs. optocoupler edge speed: Older ignition systems throw a lot of coil ringing and double-triggers onto the 12V tach signal line. My first instinct was to add a debounce capacitor on the GPIO pin and a parallel shunt resistor (R2) across the 4N35 input LED to raise its turn-on threshold. In practice, capacitive loading slowed down the 4N35's switching edges, and the extra shunt resistor turned out to be unnecessary once the input side was simplified to just a 2.2 kΩ current-limiting resistor (R1), a 1N4007 reverse-polarity diode (D1), and a 4.7 kΩ pull-up (R3) on GPIO 3.
  • Why stateful software gates failed: Next, I tried a stateful software filter that locked onto two consistent intervals and used an adaptive 78% blanking gate to reject ringing. The catch with a stateful gate is that rapid throttle blips can look like "too-short" intervals and get blocked, or early switch bounce at startup can poison the baseline period.
  • Stateless interval coalescing + trimmed mean: I replaced the stateful gate with stateless interval coalescing feeding a 6-pulse trimmed mean. When electrical bounce splits a real spark interval into a short sub-interval (< 3,000 µs or a fraction of a normal pulse) followed by the remainder, the firmware glues the split intervals back together instead of discarding them. That restores the true spark period before it enters a 6-sample rolling buffer (one full engine cycle), where the min and max values are dropped and the middle 4 are averaged.
  • Decoupling display smoothing from telemetry: For carburetor tuning and analysis, I stream raw, unsmoothed 6-pulse RPM at 10 Hz over USB serial (captured with CoolTerm and plotted with a Python matplotlib script). For the physical 7-segment display, I apply a separate 4 Hz exponential moving average (EMA) rounded to the nearest 5 RPM so the readout stays steady without adding lag to the CSV log.

In the gallery:

  1. Quick test clip on the center console (recorded on an earlier 14-pulse version of the filter before switching to the 6-pulse coalescing logic)
  2. Plot comparing raw noisy pulse intervals (orange) against the coalesced 6-pulse output (blue) during idle and a few throttle revs
  3. Breadboard wiring layout
  4. Schematic

Full Arduino sketch, Fritzing diagrams, and Python plotting script are up on GitHub if anyone wants to check out the code or adapt it for their own project: https://github.com/stijnmeershoek/w123_esp32_tachometer


r/esp32 • • 1d ago

I made a thing! My ESP32-C6 holiday lights are sealed shut, so every OTA update has to prove itself or roll back

11 Upvotes
The first one, lit, beside its control unit. The screen shows the time since it was last turned on.

I built holiday lights on a Waveshare ESP32-C6-LCD-1.3 with ESP-IDF 6.0.1: 32 WS2812Bs inside 3D-printed ornaments, three buttons and the onboard 240x240 screen to run the effects, and a local HTTPS portal for the rest. They run with no network at all; Wi-Fi is for the portal and for updates. Disclosure up front: most of the code was written by AI coding agents and reviewed by other models and by me; the bench work and the decisions are mine.

Simulation: the firmware's C++ engine on a PC, ornaments from CAD.

Then I sealed the enclosure with the USB-C port inside and no service hole: a port in the wall would have meant pushing the board against one side or adding an extension cable. The first flash happens before the lid goes on; every update after that comes over Wi-Fi. So the question was: how does a new image prove it can still take the next update before the device commits to it?

Short version: ESP-IDF's app rollback (CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE) does the reverting. I added a signature check before anything is written, a stricter test of "working" than "it booted", and fallbacks for when the network or HTTPS breaks. Along the way an ESP-IDF corner case turned up where ESP_OK comes back although the old image still boots.

What a new image has to get through:

  1. Signature before the first erase. The update header lists each part's size and SHA-256 and is signed with ECDSA P-256. The signing certificate must chain to a root built into the running firmware. Nothing touches flash until that passes.
  2. Spare slots. Firmware and the effects pack (the effect definitions, kept apart so new effects need no new firmware) stream into inactive partitions, hashed against the header as they arrive. otadata, which picks the boot slot, changes only when everything matches, so by design a power cut halfway leaves the old firmware booting.
  3. Probation. The new image boots in ESP-IDF's pending-verify state (ESP_OTA_IMG_PENDING_VERIFY). Its tasks must start, it must stay up at least 60 s, and within 10 minutes a paired client, normally the browser or desktop app that uploaded it, must get a real answer through the normal access-checked API. A 401 (the new build rejecting a client that is already paired) doesn't count, and neither does a 404 from a routing bug: an image that refuses everyone can't take the next update. Otherwise the bootloader goes back.
  4. Escape hatches. If the home network is gone for 20 s, the board brings up its own password-protected access point, which takes a signed update over plain HTTP; if HTTPS fails to start in a new build, plain HTTP stays up for a signed fix. Either way the signature, not the transport, decides what installs.
The 240x240 screen, rendered by the firmware's own drawing code: playing, a pairing request, an update arriving.

I tested Wi-Fi updates, rejection of a foreign signature and automatic rollback on the real board. No Secure Boot: that's an accepted risk, written down in the docs, so that anyone building their own can still flash it over USB. Someone holding the board can flash it; over the air, nothing installs without the signature.

The ESP_OK that wasn't. My first confirm step was the usual one: call esp_ota_mark_app_valid_cancel_rollback(), get ESP_OK, done. An AI reviewer I pointed at the code found a corner case in the ESP-IDF sources (esp_ota_current_ota_is_workable(), which that call relies on). Boot state lives in two otadata sectors: A holds the new image's record, still pending verification, and B holds the old image's, already valid.

  1. To mark the new image valid, ESP-IDF erases sector A and writes it back. Say the erase succeeds and the write fails: the call returns an error, as it should.
  2. A is now blank or half-written, so the only valid record left is B, and B becomes the active one.
  3. The retry, the obvious reaction to the error, finds B already marked valid, has nothing to do, and returns ESP_OK.

My firmware would have reported success, then booted the old image at the next restart. It came from reading the code, not from breaking a flash chip: I checked the source myself but haven't reproduced it on hardware. Reported as esp-idf #19413, still open.

So now, after ESP_OK, it reads the state back: esp_ota_get_state_partition() must report ESP_OTA_IMG_VALID, and esp_ota_get_boot_partition() must be the running slot. It retries five times, then restarts and rolls back. The uploader also counts an update as done only if the board reports a new boot identity and the image and effects digests of the file it sent. A matching version string proves nothing.

GitHub (MIT) · OTA design

What do you check before marking a new image valid on a device you can't reach by cable?


r/esp32 • • 1d ago

Board Review NEMA 17 jittering when being controlled by an A4988 and ESP32-S3

3 Upvotes

Hello,

I am trying to create a self balancing robot, but the steppers keep jittering when trying to balancing. I'm thinking its a gyroscopic code calibration issue (I'm using MPU6050) but I'm I am also thinking it's a physical NEMA 17 issue. As I have bought these a couple months ago, I am having doubts. If you some how know the fix to this issue, please let me know. I haven't added the PID algorithm yet and it is still jittering

Code:

```
#include <Wire.h>
#include <MPU6050.h>


// I2C Pins for ESP32-S3
#define I2C_SDA 8
#define I2C_SCL 9


// Left A4988 Stepper Pins
#define STEP_L 4
#define DIR_L  5


// Right A4988 Stepper Pins
#define STEP_R 6
#define DIR_R  7


MPU6050 mpu;


// Raw sensor registers
int16_t ax, ay, az;
int16_t gx, gy, gz;


// Kalman Filter state (X-axis)
float kalmanAngleX = 0.0;
float kalmanBiasX = 0.0;
float P[2][2] = { { 0.0, 0.0 }, { 0.0, 0.0 } };


const float Q_angle = 0.001;
const float Q_bias = 0.003;
const float R_measure = 0.03;


// Loop and stepping timers
unsigned long prevImuTime = 0;
unsigned long lastStepMicros = 0;
unsigned long stepIntervalMicros = 0;


// ================= FAST RECOVERY + SMOOTH STOP =================
float Kp = 220.0;                        // Stronger reflex (hits 2500 max by ~11.5 deg)
float targetAngle = 0.0;
const float MAX_STEPS_PER_SEC = 2500.0;  // Your verified safe ceiling
const float ACCEL_CATCH_RATE = 180.0;    // Fast ramp-up to catch falls immediately
const float DECEL_SMOOTH_RATE = 55.0;    // Gentle ramp-down near upright to stop jitter
const float FALL_LIMIT = 35.0;


float currentSignedSpeed = 0.0;         // Tracks actual ramped wheel speed (+ forward, - backward)
// ============================================================


// 1D Kalman Filter Algorithm
float getKalmanX(float newAngle, float newRate, float dt) {
  float rate = newRate - kalmanBiasX;
  kalmanAngleX += dt * rate;


  P[0][0] += dt * (dt * P[1][1] - P[0][1] - P[1][0] + Q_angle);
  P[0][1] -= dt * P[1][1];
  P[1][0] -= dt * P[1][1];
  P[1][1] += Q_bias * dt;


  float S = P[0][0] + R_measure;
  float K[2];
  K[0] = P[0][0] / S;
  K[1] = P[1][0] / S;


  float y = newAngle - kalmanAngleX;
  kalmanAngleX += K[0] * y;
  kalmanBiasX += K[1] * y;


  float P00_temp = P[0][0];
  float P01_temp = P[0][1];


  P[0][0] -= K[0] * P00_temp;
  P[0][1] -= K[0] * P01_temp;
  P[1][0] -= K[1] * P00_temp;
  P[1][1] -= K[1] * P01_temp;


  return kalmanAngleX;
}


void setup() {
  Serial.begin(115200);
  Wire.begin(I2C_SDA, I2C_SCL);
  Wire.setClock(400000);


  pinMode(STEP_L, OUTPUT);
  pinMode(DIR_L, OUTPUT);
  pinMode(STEP_R, OUTPUT);
  pinMode(DIR_R, OUTPUT);


  mpu.initialize();
  if (!mpu.testConnection()) {
    Serial.println("MPU6050 connection failed!");
    while (1);
  }


  // Pre-seed Kalman filter
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  kalmanAngleX = atan2(ay, az) * 180.0 / PI;


  prevImuTime = micros();
  lastStepMicros = micros();
  Serial.println("Step 3 (Smoothed): Proportional Catch Running...");
}


void loop() {
  unsigned long currentTime = micros();


  // 1. Read MPU6050 & compute ramped speed at 250Hz (every 4000 us)
  if (currentTime - prevImuTime >= 4000) {
    float dt = (float)(currentTime - prevImuTime) / 1000000.0;
    prevImuTime = currentTime;


    mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    float accelRoll = atan2(ay, az) * 180.0 / PI;
    float gyroXRate = (float)gx / 131.0;


    float currentAngle = getKalmanX(accelRoll, gyroXRate, dt);
    float error = currentAngle - targetAngle;


    float targetSpeed = 0.0;


    if (abs(error) > FALL_LIMIT || abs(error) < 0.8) {
      // Target is 0 when fallen or upright inside 0.8 deg deadband
      targetSpeed = 0.0;
    } else {
      // Smooth proportional curve starting cleanly from 0 (no 300-step jump!)
      targetSpeed = constrain(Kp * error, -MAX_STEPS_PER_SEC, MAX_STEPS_PER_SEC);
    }


    // Smoothly ramp currentSignedSpeed toward targetSpeed (eliminates jitter)
    // Fast ramp-up when speeding up to catch a fall; gentle ramp-down near upright
    float speedDiff = targetSpeed - currentSignedSpeed;
    bool speedingUp = (abs(targetSpeed) > abs(currentSignedSpeed)) && ((targetSpeed * currentSignedSpeed) >= 0);
    float maxStepChange = speedingUp ? ACCEL_CATCH_RATE : DECEL_SMOOTH_RATE;


    speedDiff = constrain(speedDiff, -maxStepChange, maxStepChange);
    currentSignedSpeed += speedDiff;


    if (abs(currentSignedSpeed) < 30.0) {
      stepIntervalMicros = 0;
    } else {
      if (currentSignedSpeed > 0) {
        digitalWrite(DIR_L, HIGH);
        digitalWrite(DIR_R, LOW);
      } else {
        digitalWrite(DIR_L, LOW);
        digitalWrite(DIR_R, HIGH);
      }
      stepIntervalMicros = (unsigned long)(1000000.0 / abs(currentSignedSpeed));
    }
  }


  // 2. Unobstructed Stepper Pulse Generator
  if (stepIntervalMicros > 0 && (currentTime - lastStepMicros >= stepIntervalMicros)) {
    digitalWrite(STEP_L, HIGH);
    digitalWrite(STEP_R, HIGH);
    delayMicroseconds(4);
    digitalWrite(STEP_L, LOW);
    digitalWrite(STEP_R, LOW);
    lastStepMicros = currentTime;
  }
}```

r/esp32 • • 1d ago

AI Content RideSync: open-source ESP32 action-camera remote and ride logger — looking for bench testers

0 Upvotes

I’m building RideSync because I want one handlebar control for action cameras and a local ride log, with firmware that makers can adapt to BLE-capable ESP32 boards. It is an experimental bench project, not ride-ready firmware.

The current setup is a LILYGO T-A7670E R2. The firmware brings camera adapters, group control and logging into a composed bench application. GPS needs a compatible GNSS source; motion logging needs an IMU; microSD provides local storage. Other ESP32 boards still need pin mappings, driver adaptation and physical checks.

Observed on isolated ESP32 probes: an Insta360 X5 completed three remote recording start/stop cycles and reconnect; a ONE RS completed one successful recording cycle with playable footage. Those results do not qualify the final integrated firmware. GO 3S, HERO12 and DJI adapters still need camera-specific physical testing. GPS/motion accuracy and timecode synchronization are not established.

The MIT-licensed source, wiring notes, protocol research and hardware evidence are here:

https://github.com/llazzaro/RideSync

I’d welcome contributors who can help reproduce bench results, review the BLE reconnect/state handling, or work on another ESP32 board. If you have a compatible board and camera, please share the exact board, camera model and firmware in a GitHub issue so we can plan a reproducible test. Please start on the bench before considering motorcycle installation.

Which ESP32 boards and action cameras would you want to use together?

Disclosure: this introduction was drafted with AI assistance; the linked documentation distinguishes software tests from observed hardware results.


r/esp32 • • 1d ago

I made a thing! TV/Movies on ESP32-S3

13 Upvotes

I thought it would be a good idea to watch TV/Movies on ESP32-S3 powered screen. I was able to do 24fps comfortably in most of the cases.

It requires transcoding, so something like the DLNA bridge is required. The source can be Channels DVR, DLNA or an M3U8. Works with Emby.

Waveshare boards tested

* ESP32-S3-Touch-LCD-1.54
* ESP32-S3-Touch-AMOLED-1.8
* ESP32-S3-Touch-AMOLED-2.06
* ESP32-S3-Touch-AMOLED-2.16

The best user experience - 2.06, the best battery life 2.16/1.54 - the latter boards do not make the TE pin available, so fast changing scenes may suffer.

https://github.com/hdhrgit/channelstv


r/esp32 • • 2d ago

AI Content Gaming in Linux on ESP32-S3

Thumbnail
gallery
89 Upvotes

Continuing the Linux development on the esp32-s3, got Wolfenstein 3D native Xtensa port running. Playable using a keyboard and mouse through a USB hub to the Arduino Nano ESP32.

It is software rendering and the game ran at about 15 FPS and its not because of CPU but rather because of the SPI bottleneck, running at about 26.67 MHz. We have GDMA enabled on the SPI bus which is now a new feature in this release. The display is an ST7789 1.3 inch 240x240 IPS, connected over SPI.

Here are the links to the Github and the Release for more detailed information.

Screenshots captured on device. Press F12 in game to capture screenshot which gets stored in the /tmp directory.

Little info about the system:

Board - Arduino Nano ESP32
CPU - ESP32-S3 with 8MB PSRAM and 16MB Flash @ 240MHz
OS - Linux 7.4.2 SMP (dual core) NoMMU Forkbank