Automated Lee APP conversion — ESP32-C6 firmware with touchscreen UI and web control.
AutoLee converts a manual Lee APP into a fully automated decapping machine using a stepper motor, sensorless homing, and stallguard jam detection. It runs on a tiny 1.47" touchscreen ESP32-C6 module and can also be controlled from any phone/computer via its built-in web interface.
Find the 3D-printable parts here: https://makerworld.com/en/models/2529369-autolee-conversion-kit
Support my work: https://buymeacoffee.com/kl.design
By K.L Design
This machine will crush fingers and hands without breaking a sweat. It is a motorized press driven by a NEMA 23 stepper motor with significant torque. It does not know or care if something is in the way.
- NEVER run this machine unattended.
- NEVER allow children near the machine, whether it is running or not.
- Keep your hands and fingers away from the machine at ALL times when it is powered on.
- Treat it like any industrial press — it can and will cause serious injury if misused.
The stall detection and jam protection features are designed to detect brass getting stuck in the machine — nothing more. They will not detect or protect your fingers and hands. They were never designed for that. And even for brass jams, they can fail, be misconfigured, or react too slowly. Do not rely on software to protect your body.
LIABILITY DISCLAIMER: This project is provided as-is with absolutely no warranty of any kind. The author(s) accept no responsibility or liability for any injury, damage, or loss resulting from building, modifying, or operating this machine. You build and use it entirely at your own risk.
- Sensorless calibration — automatically finds the UP and DOWN mechanical stops using TMC5160 StallGuard, no limit switches needed
- Adjustable endpoints — fine-tune UP and DOWN positions in ±1/10/100 step increments after calibration
- Fast ramp profile — 800,000 steps/s² accel/decel (RUN_DECEL) for maximum cruise time and StallGuard coverage
- Safe return-home — after a jam or stall, creeps back to UP stop using calibration speed with stall detection and retries
- Three preset profiles — Slow (15 kHz, SG=350), Normal (35 kHz, SG=15), Fast (45 kHz, SG=1)
- Per-profile StallGuard threshold — each speed has its own SG trip value, eliminating false jams when changing speed
- One-tap switching — change profile from the touchscreen or web UI; speed and SG update together instantly
- Fine-tune SG per profile — type a value directly into text inputs on the web Configuration page, or use ±1/±5 buttons on the touch screen
- Adjustable run current — 1,000–4,500 mA via web slider (default 3,500 mA)
- Overcurrent warning — values above 4,000 mA show a warning (exceeds motor rating, ensure cooling)
- Live adjustment — takes effect immediately, no restart needed
- Runtime StallGuard monitoring — reads SG2 via median-of-5 filtered SPI during operation
- Sliding counter stall detection — requires multiple consecutive high-SG readings to trigger (rejects transient spikes)
- Work zone blanking — skips SG monitoring near the DOWN endpoint where primer seating resistance is normal
- Accel/decel blanking — position-based and time-based SG ignore windows during speed transitions
- Automatic backoff — on jam detection, motor stops and backs off in the opposite direction before showing the jam screen
- Jam recovery screen — one-button return-home using the same proven sensorless homing as calibration
- Set a target count (1–9999) and the machine stops automatically when done
- Progress display — remaining count shown on the main screen during batch operation
- Works with all profiles — batch runs at whatever speed profile is active
- Stroke counter — counts each completed down-up cycle, displayed large on the main screen (max 9999)
- Resettable from touch UI or web interface
- Main screen — Counter, active speed profile indicator, calibration warning, batch remaining, buttons for Batch Run and Settings
- Settings screen — Calibrate, Configuration, Reset Counter
- Configuration screen — Speed Profile, Endpoints, Stall Guard, WiFi Info
- Speed Profile screen — Three buttons with green highlight on active, info card showing Hz + SG
- Endpoints (tuning) screen — Raw and effective endpoint values, buttons to edit UP and DOWN
- Stall Guard screen — Adjust SG trip for the active profile with ±1/±5 buttons
- Batch Run screen — Set target count with ±1/10/100 buttons, start batch
- Jam screen — Warning display with one-button return home
- WiFi screen — Shows connected SSID and IP address, Reset WiFi button to clear credentials and reboot
- Full control from any browser — responsive dark-theme UI works on phone and desktop
- Real-time updates — Server-Sent Events (SSE) push state changes at 250 ms intervals
- Main page — status, counter, RUN/STOP, calibrate, reset counter, speed profile selector, batch run controls
- Configuration page — motor current slider (1,000–4,500 mA with overcurrent warning), endpoint tuning with collapsible offsets, per-profile StallGuard text inputs, work zone adjustment
- Log page — full-height 500-line scrollable log with real-time streaming and clear button
- Firmware page — drag-and-drop OTA .bin upload with progress bar
- WiFi page — shows connection status, SSID, and IP address; change credentials, reset to AP mode
- Footer navigation — blue text links on every page to jump between all five pages
- Auto-connect — attempts saved credentials on boot, falls back to AP if it fails
- Captive portal — open AP mode (
AutoLee-Setup, no password) with DNS redirect so any device gets the setup page automatically - Network scanner — scans available WiFi networks and presents them in a dropdown
- ArduinoOTA support — update firmware from PlatformIO/Arduino IDE over the network (hostname:
autolee, password:autolee)
As of v1.8, the firmware is split into modular files for maintainability. All files must be in the same sketch folder.
| File | Purpose |
|---|---|
AutoLee.ino |
Main entry point — globals, setup(), loop(), include order |
config.h |
All tuning constants, pin definitions, speed profiles |
motion.h |
Motion control, stall detection, calibration, creep home |
ui_touch.h |
LVGL touch UI — screen builders, helpers, event handlers |
web_server.h |
Web server, API endpoints, SSE broadcast, HTML, OTA upload |
wifi_ota.h |
WiFi connection, captive portal, ArduinoOTA |
globals.h |
Reference document — lists all shared variables and forward declarations (not included in the build) |
lv_conf.h |
LVGL configuration — display size, enabled features, font selections |
The Arduino IDE compiles everything as a single translation unit. Include order in AutoLee.ino resolves all dependencies: config.h → globals → motion.h → ui_touch.h → wifi_ota.h → web_server.h.
Support this project: The product links below are affiliate links. If you purchase through them, I earn a small commission at no extra cost to you — it's a simple way to help fund continued development of AutoLee. Thank you!
| # | Component | Specs | Link |
|---|---|---|---|
| 1 | WaveShare 1.47" ESP32-C6 | Touchscreen controller & UI | Amazon.se · Amazon.com |
| 2 | TMC5160T Plus | Silent stepper driver with StallGuard2 | Amazon.se · Amazon.com |
| 3 | Buck Converter | 24 V → 5 V | Amazon.se · Amazon.com |
| # | Component | Specs | Link |
|---|---|---|---|
| 4 | NEMA 23 Stepper Motor | 2.4 Nm, 4.0 A, 57×57×82 mm, 8 mm shaft | Amazon.se · Amazon.com |
| 5 | Shaft Coupling | Motor-to-leadscrew (8 mm to 10 mm) | Amazon.se · Amazon.com |
| 6 | Ball Screw Kit SFU1605 250 mm | 250mm SFU1605 BK12/BF12 10 mm Shaft | Amazon.de · Amazon.com |
| # | Component | Specs | Link |
|---|---|---|---|
| 7 | Power Supply | 24 V, 5 A DC | Amazon.se · Amazon.com |
| 8 | On/Off Switch | Panel mount | Amazon.se · Amazon.com |
| 9 | DC Power Jack | 2.5 mm socket | Amazon.se · Amazon.com |
| 10 | Emergency Stop | Button | Amazon.se · Amazon.com |
| # | Component | Specs | Link |
|---|---|---|---|
| 11 | Fan | 24 V, 40×40×20 mm | Amazon.se · Amazon.com |
| # | Component | Specs | Link |
|---|---|---|---|
| 12 | Silicone Wire | 18 AWG, 24 V power wiring (PSU → driver) | Amazon.com |
| 13 | Silicone Wire | 24 AWG, flexible stranded, signal wiring | Amazon.com |
| 14 | Dupont Connector Kit + Crimping Tool | 2.54 mm connectors, housings, and ratcheting crimper | Amazon.com |
| 15 | Ferrule Connector Kit + Crimping Tool | For power and motor wires to TMC5160 terminal block | Amazon.com |
| Qty | Size | Used For |
|---|---|---|
| 15 pcs | M4 x 16mm | Motor, Motor mount, Backplane upper, Backplane lower |
| 11 pcs | M5 x 40mm | Ballscrew mounts, Sled clamp |
| 4 pcs | M5 x 25mm | Sled mount |
| 1 pcs | M4 x 20mm | Display mount |
| 4 pcs | M3 x 30mm | 24V Fan |
| 4 pcs | M3 x 5mm | TMC5160T |
| 1 pcs | M3 x 10mm | Driverhousing mounting to backplane |
| 2 pcs | M3 x 10mm | Driverhousinglid |
| 4 pcs | M2 x 5mm | Display |
| Qty | Size | Used For |
|---|---|---|
| 3 pcs | M5 Lock nut | Sled clamp |
| 4 pcs | M3 Lock nut | 24V Fan |
| Qty | Size | Used For | Link |
|---|---|---|---|
| 16 pcs | M4 Heat insert | Motor, Motor mount, Backplane upper, Backplane lower, Display mount | Amazon.se · Amazon.com ¹ |
| 8 pcs | M5 Heat insert | Ballscrew mount | Amazon.se · Amazon.com ¹ |
| 5 pcs | M3 Heat insert | TMC5160T mount, Driverhousing to backplane | Amazon.se · Amazon.com ¹ |
¹ The US link is a bundle kit that includes M3, M4, and M5 inserts.
| ESP32-C6 Pin | TMC5160 Pin | Function |
|---|---|---|
| GPIO 1 | SCK | SPI Clock |
| GPIO 2 | SDI (MOSI) | SPI Data In |
| GPIO 3 | SDO (MISO) | SPI Data Out |
| GPIO 8 | CS | SPI Chip Select |
| GPIO 4 | EN | Enable (active low) |
| GPIO 5 | STEP | Step pulse |
| GPIO 6 | DIR | Direction |
| GPIO 7 | DIAG1 | StallGuard diagnostic output |
| Connection | Details |
|---|---|
| 24 V PSU → TMC5160 VM | Motor power (24 V) |
| 24 V PSU → Buck converter IN | Feeds the buck converter |
| Buck converter OUT (5 V) → ESP32-C6 | Logic power |
| 24 V PSU → Fan | Direct 24 V to cooling fan |
| GND | Common ground between all boards |
Important: The display and TMC5160 share the SPI bus (GPIO 1, 2). The firmware manages chip-select lines (GPIO 8 for TMC, GPIO 14 for display) to avoid bus conflicts. The display CS is forced high before every StallGuard SPI read.
| Library | Version | Install | Purpose |
|---|---|---|---|
LVGL |
v8.4.0 | Online | Touchscreen UI framework |
GFX_Library_for_Arduino |
v1.5.9 | Online | ST7789 display driver |
TMCStepper |
— | Online | TMC5160 SPI communication |
FastAccelStepper |
— | Online | Step pulse generation with acceleration |
ESPAsyncWebServer + AsyncTCP |
— | Online | Web server & SSE |
ArduinoOTA |
— | Online | Over-the-air firmware updates |
DNSServer |
— | Online | Captive portal redirect |
esp_lcd_touch_axs5106l |
— | Offline | AXS5106L touch controller driver |
Note: The
esp_lcd_touch_axs5106llibrary is not available in the Arduino Library Manager. You must install it manually from Waveshare's demo package — see step 3 below.
- Clone this repo
- Install all "Online" libraries above via the Arduino Library Manager
- Install the touch driver offline:
- Download the Waveshare ESP32-C6-Touch-LCD-1.47 demo package
- Find the
esp_lcd_touch_axs5106llibrary folder inside the package - Copy it to your Arduino
librariesdirectory
- Set up LVGL:
- Copy
lv_conf.hfrom this repo to sit next to yourlvgllibrary folder (not inside it) - Copy the
demosfolder from inside the LVGL library into itssrcfolder
- Copy
- Open
AutoLee.inoin Arduino IDE or PlatformIO — all.hfiles must be in the same folder as the.ino - Select board: ESP32-C6
- Set partition scheme: Minimal SPIFFS (1.9 MB APP with OTA/190 KB SPIFFS) — the firmware is too large for the default partition layout
- Compile and flash
If you don't want to set up the Arduino IDE and compile the firmware yourself, you can flash a pre-built binary directly to the ESP32-C6 using a web browser.
- A Chrome or Edge browser (Web Serial is not supported in Firefox or Safari)
- A USB-C cable connected to the Waveshare ESP32-C6 board
- The merged firmware
.binfile from the/Firmwarefolder in this repo
- Download the latest
AutoLee_vX.X_merged.binfrom the/Firmwarefolder - Open the Espressif Web Flasher in Chrome or Edge
- Click Connect and select the port for your ESP32-C6
- In the Program section, enter
0x0in the Flash Address field - Click the file picker next to the address and select the downloaded
.binfile - Set Flash Mode as dio and Flash Size as 4MB
- Click Program
- Wait for flashing to complete — progress will show in the Console section at the bottom
- After programming is complete click the rst button on the esp32 board to reboot
- System should now be online
Tip: If the board doesn't show up as a COM port, hold the BOOT button on the Waveshare board while plugging in USB, then release after connecting. You may also need to install the CH343 USB driver if your OS doesn't recognize the board.
Once AutoLee is on your WiFi, go to the web UI → Firmware page and drag-and-drop the app-only .bin file (not the merged binary). The merged binary is only needed for the initial USB flash.
After first flash, firmware can be updated two ways:
- Web UI — open the AutoLee web interface, go to the Firmware page, drag and drop a
.binfile - ArduinoOTA — hostname
autolee, passwordautolee
Key constants are in config.h:
| Constant | Default | Description |
|---|---|---|
profiles[0] (Slow) |
15,000 Hz / SG 350 | Low speed, high SG threshold — max torque for tough primers |
profiles[1] (Normal) |
35,000 Hz / SG 15 | Balanced speed and sensitivity |
profiles[2] (Fast) |
45,000 Hz / SG 1 | High speed, very sensitive stall detection |
RUN_CURRENT_MA |
3,500 mA | Motor run current (adjustable 1,000–4,500 via web UI) |
RUN_DECEL |
800,000 | Accel/decel rate (steps/s²) |
CAL_CURRENT_MA |
3,200 | Calibration current (mA, fixed) |
CAL_SPEED_HZ |
8,000 | Calibration speed (Hz) |
SG_WORK_ZONE_STEPS |
5,500 | SG blanking zone near DOWN endpoint |
DOWN_OFFSET_DEFAULT |
−500 | Default DOWN endpoint offset after calibration |
CAL_SGT |
−1 | StallGuard sensitivity for calibration |
All endpoints accept POST requests.
| Endpoint | Parameters | Description |
|---|---|---|
GET /api/state |
— | Returns full JSON state |
/api/toggle_run |
— | Start or stop running |
/api/profile |
idx=0|1|2 |
Switch speed profile |
/api/sg_trip |
value=N or delta=N, &profile=N (optional) |
Set or adjust SG threshold; targets active profile by default |
/api/current |
ma=N |
Set motor run current (1,000–4,500 mA) |
/api/work_zone |
delta=N |
Adjust work zone blanking steps |
/api/endpoint |
which=up|down &delta=N |
Adjust endpoint offset |
/api/batch |
delta=N or action=start|clear |
Adjust batch target or start/clear |
/api/action |
do=calibrate|return_home|reset_counter |
Trigger actions |
/api/wifi |
ssid=... &pass=... |
Save WiFi credentials and reboot |
/api/wifi_reset |
— | Clear saved WiFi, reboot to AP mode |
/api/ota |
multipart .bin upload |
Firmware update |
/api/log_clear |
— | Clear the log buffer |
SSE stream available at /events — pushes JSON state every 250 ms and log lines as log events.
| Version | Changes |
|---|---|
| v1.8 | Firmware split into modular files (config.h, motion.h, ui_touch.h, web_server.h, wifi_ota.h) for maintainability — no functional changes from v1.7 |
| v1.7 | WiFi Info moved to Configuration sub-menu; Reset WiFi button on WiFi info screen; speed profile buttons resized to fit display; WiFi info centered in card |
| v1.6 | Adjustable motor current (1,000–4,500 mA) via web; multi-page web UI (Main, Configuration, Log, Firmware, WiFi); touch UI restructured (Settings → Configuration sub-menu); WiFi page shows SSID + IP; SG text inputs with auto-submit on blur; profiles retuned (Slow 15kHz/350, Normal 35kHz/15, Fast 45kHz/1); all labels fitted to 172px display |
| v1.5 | Speed profiles (Slow/Normal/Fast) replace speed slider; per-profile SG thresholds; profile API |
| v1.4 | Captive portal WiFi; work zone SG blanking; RUN_DECEL 800k; median-of-5 SPI filter; sliding counter stall detection; 500-line log; redesigned web UI |
| v1.3 | Batch run; jam screen with return-home; runtime StallGuard monitoring; web log viewer |
| v1.2 | Web UI with SSE; OTA updates; endpoint tuning; WiFi AP/STA |
| v1.1 | Sensorless calibration; basic touch UI |
| v1.0 | Initial release |
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
You are free to use, modify, and share this work for personal, non-commercial purposes, provided you give appropriate credit. Commercial use is not permitted without prior written permission.
Commercial use — including selling devices, kits, or services based on this project — is prohibited without prior written permission from the author.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. USE AT YOUR OWN RISK.
Copyright (c) 2025 K.L Design