Hi everyone,
I wanted to share an open-source ESP32 controller I built for automating the Z-axis on my Galvo fiber laser workstation (Raycus 30W with LightBurn).
Switching between different F-Theta lenses, varying workpiece thicknesses, and dialing in repeatable defocus offsets for stainless steel colors used to require manual cranking and measuring every time. To solve this, I wrote a modular C++ / PlatformIO firmware for the ESP32-WROOM-DA paired with a 2.42" OLED display, an EC11 rotary encoder, and an MKS SERVO57D closed-loop motor over RS485 (standard Step/Dir drivers are also supported).
Main features:
-
Multi-Lens & Material Focus: Stores calibrated focal distances for up to 6 F-Theta lenses (
70x70up to300x300), calculates $Z = H_{\text{material}} + F_{\text{lens}} + \Delta Z_{\text{color}}$ automatically, and includes built-in crash limits. -
Stainless Steel Color Offsets: 4 quick-select defocus presets (
C1–C4) for repeatable color marking. -
3D Deep Relief Engraving Mode: Enter the total job duration (
HH:MM:SS) and desired Z-depth (mm) — the controller sends an isolated relay start pulse to LightBurn’s pedal input, linearly lowers the Z-axis throughout the run to keep the focal plane inside the engraving, and retracts automatically when done. -
Power-Loss Z Persistence: Saves Z-height to NVRAM and syncs with the MKS SERVO57D 48-bit encoder at boot so the controller remembers its exact Z-position across full power cycles.
-
Two-Stage Precision Homing & In-Menu Calibration: Includes a first-boot setup wizard, live focus calibration, and built-in motor calibration.
GitHub Repository (Firmware, Pinouts & Documentation):
Next step is designing a dedicated KiCad PCB to house everything cleanly inside the control box. Feedback, ideas, or pull requests are very welcome!