This project enables the remote control of a stepper motor using two ESP32 devices via ESP-NOW communication.
The system consists of:
- A Sender ESP32, connected to a rotary encoder and a touch sensor for mode selection.
- A Receiver ESP32, controlling a stepper motor via a DRV8825 driver.
The project provides:
- Accurate stepper motor control based on encoder input.
- Three user-selectable modes (Fine, Normal, Fast) for controlling the movement speed.
- Status indication via LEDs and a touch sensor interface.
- ESP-NOW: A lightweight, peer-to-peer communication protocol for ESP32, used for fast and reliable data exchange.
- PlatformIO: An integrated development environment (IDE) for ESP32 development.
- Rotary Encoder: For generating step changes.
- DRV8825: A stepper motor driver for motor control.
- Touch Sensor (TTP223): For mode switching.
- Navigate to the
StepperController/src/
folder and rename the fileFindMACAddress.cpp__
toFindMACAddress.cpp
. - Compile and upload the file to the Receiver ESP32 using PlatformIO.
- The MAC address will be displayed in the Serial Monitor. Use this address in the Sender code (
Sender.cpp
).
Note: Ensure only one .cpp
file is active in the src
folder by renaming other .cpp
files with __
at the end (e.g., FindMACAddress.cpp__
).
- Navigate to the
StepperController/src/
folder. - Rename
Receiver.cpp__
toReceiver.cpp
. - Compile and upload the code to the Receiver ESP32 using PlatformIO.
- Follow the wiring instructions provided in the file header to connect the stepper motor, DRV8825 driver, and LEDs.
- Navigate to the
RotaryEncoderController/src/
folder. - Open
Sender.cpp
and replace thereceiverMAC[]
variable with the MAC address of the Receiver ESP32 obtained in Step 1. - Compile and upload the code to the Sender ESP32 using PlatformIO.
- Follow the wiring instructions provided in the file header to connect the rotary encoder, LEDs, and touch sensor.
For detailed wiring instructions, refer to the header comments in each .cpp
file.
All necessary GPIO pin mappings and configuration details are documented in each code file.
ESP32-Stepper-Controller
├── 3DprintingRelated/ # STL files for 3D printing the enclosure
│ ├── 3Drenderings/ # Rendered images of the enclosure design
│ │ ├── rend1.png
│ │ ├── rend2.png
│ │ ├── rend3.png
│ │ ├── rend4.png
│ │ └── rend5.png
│ ├── STLprintingFiles/ # STL files for 3D printing
│ │ ├── BOTTOM.stl
│ │ ├── FEETS.stl
│ │ └── TOP.stl
│ └── Fusion360designFile.f3d # Modifiable Fusion 360 design file
├── Documentation/ # Component details and sources
│ ├── Pictures/
│ │ ├── housingClosed.png # Photo of the closed housing
│ │ └── housingOpen.png # Photo of the open housing with components
│ ├── ESP32 Manual MLA...pdf # Documentation for the ESP32 MLA components
│ └── Rotary Encoder.pdf # Rotary Encoder details and source
├── RotaryEncoderController/ # Code for the Sender ESP32
│ ├── src/
│ │ ├── IOTest.cpp__ # Test script for rotary encoder connections
│ │ ├── Sender.cpp # Main sender code
│ │ ├── platformio.ini # PlatformIO configuration (no changes needed)
│ │ └── README.md # Folder-specific instructions
├── StepperController/ # Code for the Receiver ESP32
│ ├── src/
│ │ ├── FindMACAddress.cpp__ # Script to find receiver MAC address
│ │ ├── IOTest.cpp__ # Test script for stepper motor connections
│ │ ├── Receiver.cpp # Main receiver code
│ │ ├── platformio.ini # PlatformIO configuration (no changes needed)
│ │ └── README.md # Folder-specific instructions
└── README.md # Main project instructions
- The
Documentation
folder contains information about all the components used in this project, including their sources (AliExpress, etc.). - The
3DprintingRelated
folder includes STL files for printing the enclosure of the project.
Video showcasing the project in action.