ESP32-based electric vehicle controller for Razor ride-on toy conversion
Advanced dual motor control with safety systems and telemetry
Transform a Razor ride-on toy into a professional electric vehicle with:
- 6-Speed Electronic Transmission (Park, 1st, 2nd, 3rd, Eco, Sport+)
- Dual Independent Motor Control with current monitoring
- Multi-Layer Safety Systems with fault detection
- GPS Geofencing with automated speed limits and boundaries
- WiFi Web Interface for smartphone monitoring and control
- Advanced Telemetry (GPS, voltage, current, power, efficiency)
- OLED Dashboard with rotary encoder interface
- 4-Zone LED Lighting with auto modes and animations
- Platform: ESP32-WROOM-32 (240MHz dual-core with optimized task distribution)
- Architecture: Dual-core real-time system (Core 1: Safety/Motors, Core 0: WiFi/Web)
- Power: 60V Li-ion battery (15S, 54-63V range)
- Motors: 2Γ 30V DC motors via Cytron MDD20A driver
- Current Monitoring: 3Γ INA228 sensors (0.001Ξ© shunts)
- Display: 128Γ64 OLED with rotary encoder
- GPS: GT-U7 module for speed/position tracking
- WiFi: Built-in ESP32 WiFi for web interface
- Lighting: PCA9685 PWM controller for 4-zone LEDs
- ESP32-WROOM-32 development board
- Cytron MDD20A dual motor driver
- 3Γ Adafruit INA228 current sensors
- PCA9685 PWM driver board
- SSD1306 OLED display (128Γ64)
- GT-U7 GPS module
- Rotary encoder with push button
- 10kΞ© potentiometer (pedal sensor)
- Power converters: 60Vβ30V (600W), 60Vβ12V (120W), 12Vβ5V (3A)
| GPIO | Function | Device |
|---|---|---|
| 21 | I2C SDA | All I2C devices |
| 22 | I2C SCL | All I2C devices |
| 32 | Motor PWM L | MDD20A Channel A |
| 12 | Motor PWM R | MDD20A Channel B |
| 34 | Pedal ADC | 10kΞ© Potentiometer |
| 15 | Key Switch | SPST Switch (10kΞ© pulldown) |
| 25 | Encoder CLK | Rotary Encoder |
| 26 | Encoder DT | Rotary Encoder |
| 27 | Encoder BTN | Push Button |
| 33 | Shift Up | KEY0 Button |
| 13 | Shift Down | KEY1 Button |
| 16 | GPS RX | GT-U7 TX |
- 0x40: Battery Monitor (INA228)
- 0x41: Left Motor Monitor (INA228)
- 0x44: Right Motor Monitor (INA228)
- 0x70: Light Controller (PCA9685)
- 0x3C: OLED Display (SSD1306)
- PowerManager: Triple INA228 monitoring, battery SOC, energy tracking
- MotorController: Dual PWM control, gear curves, acceleration ramping
- LightController: 4-zone LED control, auto modes, gear animations
- UserInterface: OLED display management, multiple screens
- InputHandler: Pedal ADC, encoder, buttons with debouncing
- Navigation: GPS parsing, speed calculation, odometer, geofencing
- Geofencing: GPS-based boundaries, speed limits, safety zones
- WebInterface: WiFi access point, REST API, mobile dashboard
- CoreManager: Dual-core task scheduler with real-time guarantees
- SafetySystem: Fault detection, current limiting, watchdog timer
- StateMachine: System coordination, state management
| Gear | Max Power | Curve | Character |
|---|---|---|---|
| Park | 0% | N/A | Disabled |
| 1st | 40% | Gentle | Learning mode |
| 2nd | 70% | Linear | Normal cruising |
| 3rd | 100% | Sporty | Full power |
| Eco | 60% | Smooth | Battery conservation |
| Sport+ | 110% | Aggressive | 10-second timeout |
- Low Voltage Protection: Shutdown at 54V
- Overcurrent Protection: 20A per motor, 20A battery
- Motor Stall Detection: High current + no movement
- Motor Balance Monitoring: Warn at 15%, fault at 30%
- Key Switch Enforcement: No operation without key
- Watchdog Timer: Reset if system hangs
- GPS Geofencing: Automated speed limits and prohibited zones
The advanced geofencing system provides GPS-based safety controls:
- Safe Zones: Designated safe operating areas
- Speed Limits: Automatic speed reduction in specific areas
- Prohibited Zones: No-entry areas with automatic stop
- Emergency Boundaries: Auto return-to-home beyond limits
- Real-time Monitoring: Continuous GPS position tracking
For detailed geofencing setup and configuration, see GEOFENCING_GUIDE.md.
Optimized task distribution across ESP32's dual-core processor:
- Core 1 (Real-Time): Safety monitoring (100Hz), motor control (50Hz), navigation (10Hz)
- Core 0 (Communication): WiFi stack, web interface, background tasks
- Thread-Safe Communication: Mutex-protected shared data between cores
- Deterministic Timing: Guaranteed response times for safety-critical functions
- Performance Monitoring: Real-time task execution and memory usage tracking
For complete architecture details, see DUAL_CORE_ARCHITECTURE.md.
Monitor and control your vehicle remotely via smartphone:
- Real-time Dashboard: Battery, motors, GPS, geofencing status
- Remote Controls: Emergency stop, gear changes, trip reset
- Geofence Management: Add/remove boundaries, set speed limits
- Mobile Optimized: Responsive design for all devices
Quick Connect: Look for WiFi network RazorsEdge-Controller, password RazorEdge2025, then browse to http://192.168.4.1
For complete WiFi setup and mobile app development, see WIFI_GUIDE.md.
# Install PlatformIO
pip install platformio
# Clone or download project
# Open in VS Code with PlatformIO extension- Wire ESP32 according to pin assignments
- Connect all I2C devices to bus (SDA/SCL)
- Install current sensors in power paths
- Connect motors to MDD20A driver
- Wire power distribution system
- CRITICAL: Install 10kΞ© pull-down on GPIO 15
# Compile project
pio run
# Upload to ESP32
pio run --target upload
# Monitor serial output
pio device monitor- I2C Scan: Verify all 5 devices respond
- Power Monitoring: Check voltage/current readings
- Display Test: Verify OLED shows startup screen
- Input Test: Check pedal, buttons, encoder
- Motor Test: Low power with wheels off ground
- Integration: Full system test in safe area
I2C Device Not Found
- Check wiring (SDA/SCL, power, ground)
- Verify device addresses
- Add pull-up resistors if needed
Motor Won't Run
- Verify key switch is ON
- Check 30V motor power supply
- Ensure MDD20A error LED is off
- Confirm PWM signals present
Erratic Pedal Reading
- Increase ADC filtering
- Check 3.3V supply stability
- Calibrate min/max values
ESP32 Won't Boot
- Verify GPIO 15 has 10kΞ© pull-down
- Check 5V power supply
- Remove all connections, test bare ESP32
Monitor serial at 115200 baud for:
- Module initialization status
- I2C device detection
- Current/voltage readings
- Fault codes and warnings
- State transitions
DANGER - High Voltage System
- 60V can cause serious injury or death
- Always disconnect battery before working
- Use appropriate safety equipment
- Test thoroughly before road use
Motor Safety
- Sport+ mode can damage motors if overused
- Monitor motor temperatures during testing
- Respect current limits
- Emergency stop must always be accessible
Battery Safety
- Use proper Li-ion charging procedures
- Never discharge below 54V (3.6V/cell)
- Monitor cell balance
- Install appropriate fuses
- PROJECT_CONTEXT.md: Complete technical specifications
- platformio.ini: Library dependencies and build config
- src/config.h: All pin assignments and constants
- src/*.h: Module header files with API documentation
This is a specialized embedded project. Contributions welcome for:
- Additional safety features
- Performance optimizations
- Documentation improvements
- Testing procedures
This project is for educational and experimental use. Use at your own risk.
Build Status: β
Code Complete - Ready for Hardware Testing
Last Updated: November 2025
Platform: ESP32 + PlatformIO + Arduino Framework