An open-source, end-to-end hardward & software solution for motorizing your smart home.
ESP32 Yun is an affordable, reliable, and user-friendly wireless stepper motor controller that works with two-phase bipolar stepper motors. It comes with a web user-interface for intuitive controls and HTTP restful APIs for custom integrations.
Under active development.
- 📡 WiFi-based: no need for extra hub
- 🔄 Closed-loop system: motor can be manually moved without losing track of its position
- 🛑 Automatic stalling detection and stopping: preventing injuries and protecting the motor
- 🤖 Custom hardware: few parts, cheap and relatively easy to assemble
- 🖥️ Web UI: no need to download app to control motor or change settings, works on desktop/mobile devices
- 🌐 HTTP restful APIs: easy to create integrations for smart home platforms
- 😶 Extremely quiet, won't even wake a baby!
- 🚀 Can go really fast!
Please see demo video for full demonstration!
There are three components: electronics, firmware, and mounting hardware.
- USB-to-TTL serial adatper to upload the firmware
- Soldering iron, wires, and JST PH connectors/crimper
- Two-phase bipolar stepper motor, such as a Nema 11
- Magnet for the rotary encoder
- Power supply: 3.3-9V, 1.2A max
- (Optional) 3D printer for the motor mount
Please refer to the electronics folder.
[schematic][gerber files][bom][pick-and-place file]
Flash the firmware via VSCode + PlatformIO.
- espressif32@3.5.0
- TMCStepper@^0.7.3
- FastAccelStepper@^0.27.5
- robtillaart/AS5600@^0.4.1
- ESPAsyncWebServer
- ArduinoJson@^7.0.4
- LittleFS_esp32@^1.0.6
- Clone this repository.
- Double check and set proper current sense resistor value in platformio.ini.
- Set the USB-to-TTL serial adatper's logic level to 3V3 and plug it in to the computer.
- Keep holding the button on ESP32 Yun and start flashing the firmware.
- Once the IDE begins data transmition, connect the four wires from ESP32 Yun to the adapter: RX to TXD, TX to RXD, + to VCC, and − to GND.
- Let go of the button once the firmware starts uploading. Unplug ESP32 motorcover after the firmware has finished uploading.
You can find the stl and pre-sliced files under the cad folder. To mount the magnet for the rotary encoder, it is recommended to use the manget gluing jig to make sure that the magnet is centered on the axis-of-rotation; otherwise, it could affect the accuracy of the rotary encoder.
During the first time booting up, ESP32 Yun is put into setup mode and it functions as a WiFi access point. Connect to it with your device like you would connect to a WiFi network. After connection is established, open a web browser and go to the IP address 192.168.4.1 to access the web UI. There you can enter your WiFi network credentials and change other settings.
All RestAPIs are implemented as HTTP GET requests. To control the motor or change any settings, use http://<ESP32-YUN-IP-ADDRESS>/<URI>?<PARAM>=<VALUE>. For example: http://192.168.4.1/motor?percent=0. There are four URIs: motor, system, wireless, and json.
- stop: stop the motor
- percent: move the motor to the specified percentage
- step: move the motor to the specified step
- forward: run the motor foward continuously
- backward: run the motor backward continuously
- set-min: set the beginning endpoint
- set-max: set the ending endpoint
- zero: set the current motor position to zero
- standby: put the motor driver into standby to reduce power consumption
- sync-settings: sync open/closing settings for current, velocity, and acceleration
- velocity: set both opening and closing velocity
- opening-velocity: set opening velocity
- closing-velocity: set closing velocity
- acceleration: set opening and closing acceleration
- opening-acceleration: set opening acceleration
- closing-acceleration: set closing acceleration
- current: set opening and closing current
- opening-current: set opening current
- closing-current: set closing current
- direction: change the direction of the motor
- full-steps: set the number of full steps per turn
- microsteps: set the number of subvisions per full step
- stallguard: enable/disable stallguard
- coolstep-threshold: set threshold to enable stallguard and coolstep
- stallguard-threshold: set threshold to trigger stallguard
- fastmode: set to exclusively use fastmode, i.e. SpreadCycle
- fastmode-threshold: set threshold to automatically switch over to fastmode
- sleep: put ESP32 Yun into standby
- restart: restart the system
- reset: reset all settings to factory settings
- name: rename the system
- setup: setup mode
- ssid: ssid of your WiFi network
- password: passowrd of your WiFi network
Use HTTP GET request http://<ESP32-YUN-IP-ADDRESS>/json to get all settings in a Json object.
- Toggle setup mode: press and hold down for 5 seconds till the led turns on
- Factory reset: press and hold down for 15 seconds till the led turns off after it turns on at 5 seconds
StallGuard4 (SG) is a feature of the motor driver, TMC2209, which provides automatic stall detection and stopping. SG requires some trial-and-error as well as some patience to get it working correctly. Please refer to the TMC2209 datasheet, chapter 16, page 70.
- Custom drivers to reduce dependency and firmware size
- Updating PCB so little-to-no soldering is required
- Replace ESP32 WROOM 32E so USB-to-TTL is not required to flash the firmware
- BLE support
- Ultra-low power for battery application