Skip to content

About

PlatformIO ESP32 motor driver project for DRV8871

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DRV8871 Motor Driver Tester for ESP32-C3 & N20 DC Motor

PlatformIO test codebase for controlling a DC Geared Mini Motor (N20 6V 100RPM) using an ESP32 Mini C3 microcontroller and a DRV8871 H-Bridge motor driver powered by a 12V power supply.


⚡ Hardware Connections

Wiring Diagram

Component Pin Connects To Notes
DRV8871 IN1 ESP32-C3 GPIO 4 PWM Control Pin 1
DRV8871 IN2 ESP32-C3 GPIO 5 PWM Control Pin 2
DRV8871 GND ESP32-C3 GND & 12V PSU GND Common Ground (Mandatory!)
DRV8871 VM +12V Power Supply Driver Power Input (6.5V - 45V)
DRV8871 OUT1 Motor Terminal 1 N20 Motor Output
DRV8871 OUT2 Motor Terminal 2 N20 Motor Output
ESP32-C3 5V/VBUS 5V Power / USB Power ESP32 via USB or step-down buck

Warning

Motor Protection Guard (12V Supply with 6V Motor): The N20 mini motor is rated for 6V, while the main power supply is 12V. The code automatically limits the maximum PWM duty cycle to 50% (128/255). This provides an effective average output voltage of ~6V across the motor terminals to prevent winding burn-out or gear overheating.


🚀 How to Build and Upload

1. Requirements

2. Build the Project

Open terminal in the root directory of this project and run:

pio run

3. Upload to ESP32 Mini C3

Connect your ESP32 Mini C3 via USB and run:

pio run -t upload

4. Open Serial Monitor

Launch the serial monitor at 115200 baud:

pio device monitor

🎮 Serial CLI Commands

Once the monitor is running, type commands into the terminal and press Enter:

Command Action
f or F Drive motor FORWARD at configured speed percentage
r or R Drive motor REVERSE at configured speed percentage
s or S STOP (Coast / Float mode)
b or B BRAKE (Fast decay mode)
0 - 100 Set speed percentage (e.g. 75 sets speed to 75% of max safe 6V level)
t or T Run automated RAMP SWEEP test sequence
h or ? Display Help Menu

About

PlatformIO ESP32 motor driver project for DRV8871

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages