- Implement MotorController class with PWM speed control (0-100%) - Add bidirectional control (forward/reverse) via LEDC PWM at 20kHz - Include optional current sensing and stall detection - Create responsive web UI with speed slider and direction buttons - Configure WiFi with static IP (10.81.2.185) - Use built-in WebServer library for ESP32 Arduino 3.x compatibility
1.2 KiB
1.2 KiB
AGENTS.md
This file provides guidance to agents when working with code in this repository.
Project Overview
PlatformIO project for ESP32 LOLIN32 Rev1 controlling BTS7960 dual H-bridge motor driver (12V DC).
Build Commands
pio run # Build
pio run -t upload # Build and upload
pio device monitor # Serial monitor (115200 baud)
Hardware-Specific Notes
- Board: ESP32 LOLIN32 Rev1 (use
lolin32in platformio.ini) - Motor Driver: BTS7960 dual H-bridge - requires 4 GPIO pins (RPWM=25, LPWM=26, R_EN=27, L_EN=14)
- Power: 12V DC input to motor driver - logic level is 3.3V compatible with ESP32
- WiFi: Connects to SSID 'tami' with static IP 10.81.2.185
- Reference: https://deepbluembedded.com/arduino-bts7960-dc-motor-driver/
Non-Obvious Notes
- Use built-in
WebServerlibrary (NOT ESPAsyncWebServer - has enum compatibility issues with ESP32 Arduino 3.x) - WebServer requires
handleClient()call in loop() - unlike async version - LEDC PWM at 20kHz reduces motor noise
- Enable pins (R_EN, L_EN) must be HIGH before PWM works
- BTS7960 is 3.3V compatible: Inputs are TTL/CMOS compatible (VIL<0.8V, VIH>2.0V) - ESP32 GPIOs work directly without level shifters (per BTN7960 datasheet section 5.4.1)