Skip to content

Wireless Stepper Motor Controller with ESP32 and TMC2240

Project Overview and Highlights

This project presents a compact, intelligent wireless stepper motor controller, enabling users to remotely control the motor via a web browser. The main features include:

  • Wireless control: Real-time position, speed, and direction adjustment through a web interface.
  • High precision: Supports up to 1/256 microstepping, with closed-loop feedback using the AS5600 magnetic encoder.
  • Smart power management: USB-C Power Delivery (PD) with automatic voltage negotiation (5V~20V).
  • Real-time monitoring: Displays motor position, temperature, current, and more.
  • Visual feedback: RGB LED indicates system status and motor activity.

Main Components

  • ESP32-S3-WROOM-1: Dual-core microcontroller with Wi-Fi/Bluetooth, provides web server and SPI/I²C communication.
  • TMC2240ATJ+T (Analog Devices): High-precision stepper driver, supports 2A current, ultra-quiet operation, SPI configuration, and diagnostics.
  • AS5600-ASOM: 12-bit non-contact magnetic rotary position sensor for precise angle feedback (closed-loop control).
  • FUSB302BMPX (onsemi): USB-C PD controller for voltage negotiation.
  • ADPL44002AUJZ (or other LDO): Stable 3.3V logic power supply.
  • Others: RGB LED, buttons, TVS protection diodes, MOSFETs, etc.

Hardware Design and PCB

The custom PCB is designed with KiCad, measuring only 42.3mm × 42.3mm, perfectly matching the NEMA17 stepper motor and can be mounted directly on the motor's back.

  • Power: USB-C via FUSB302 negotiates voltage, LDO steps down to 3.3V.
  • Control: ESP32 configures TMC2240 via SPI, drives the motor with STEP/DIR pulses; reads AS5600 position and PD status via I²C.
  • Protection: TVS diodes for surge protection, current sense resistors for load monitoring.

Assembly and Enclosure

  1. Solder SMD components (recommended stencil + reflow, or manual soldering).
  2. Laser-cut acrylic/materials for a simple enclosure (with spacers for encoder height).
  3. Attach a small magnet (about 3mm diameter) to the motor shaft, aligned with the AS5600.
  4. The final assembly is compact, with the driver IC exposed for better heat dissipation.

Software and Firmware

  • Development environment: Arduino IDE or PlatformIO.
  • Key libraries: WiFi, WebServer, AS5600, PD_UFP, ArduinoJson, SPI, etc.
  • Features:
  • Wi-Fi AP/Station mode, hosts web pages.
  • Non-blocking operation: web server remains responsive during motor movement.
  • Supports microstep configuration, speed control, position feedback, emergency stop, etc.
  • Web interface: Mobile-friendly, allows setting voltage, speed, steps, target angle, and displays real-time status.

Application Scenarios

  • Robotic arm precise movement
  • CNC/laser engraving positioning
  • Smart home curtain/valve control
  • Rapid prototyping and educational projects

Summary

This project demonstrates the potential of ESP32 combined with a high-end driver, leveraging wireless and closed-loop feedback to greatly enhance the convenience and precision of traditional stepper control.

Project repository: https://github.com/Circuit-Digest/Wireless-Stepper-Motor-Controller

References