A professional FreeRTOS-based vehicle control unit for ESP32-S3 with a modern web interface for real-time monitoring and configuration.
- FreeRTOS Multi-tasking: Three dedicated tasks for CAN communication, control logic, and web server
- Advanced Pedal Control: Three-zone system (Regen/Coast/Accel) with smooth torque transitions
- CAN Bus Integration: Manages BMS, DMC, BSC, and NLG subsystems
- Persistent Configuration: JSON-based flash storage with validation
- Real-time Monitoring: Error logging, performance metrics, and system health checks
- Always-On Web Server: Configure and monitor from any device on the network
- Modern Dashboard: Real-time charts for speed and power, live vehicle status
- Tabbed Interface:
- Dashboard: Live monitoring with gauges and graphs
- Charging: Configure charging current and target SOC
- Configuration: Driving modes, pedal zones, torque transitions
- CAN Monitor: Live CAN bus message viewer
- Task Monitor: FreeRTOS task statistics
- System: WiFi settings, debug mode, firmware info
- WebSocket Updates: 10Hz real-time data streaming
- Dark Theme: Professional automotive UI with purple/blue accents
- ESP32-S3 DevKit C1
- Dual-core ARM @ 240 MHz
- 16 MB Flash, 8 MB SRAM
- MCP2515 CAN Controller (SPI)
- ADS1115 16-bit ADC (I2C)
- WiFi 802.11 b/g/n
- Dual throttle pedal inputs
- HV contactor control
- Cooling pump PWM
- Charger/inverter enable outputs
- Connector unlock interrupt
# Install PlatformIO
pip install platformio
# Build project
pio run
# Upload firmware
pio run --target upload
# Upload filesystem (web interface)
pio run --target uploadfs- Power on the VCU
- Look for WiFi network:
VCU_XXXXX(XXXXX = chip ID) - Connect with password:
vcu12345 - Open browser to:
http://192.168.4.1
- Navigate to System tab
- Enter your WiFi SSID and password
- VCU will connect to your network
- Note the new IP address displayed
- Live Data (updates every 100ms):
- Vehicle state, gear, speed, torque
- Battery SOC, voltage, current
- Motor/inverter/battery temperatures
- Throttle, regen, brake inputs
- Real-time Charts:
- Speed chart (last 100 samples)
- Power chart (positive = discharge, negative = charge)
- Set maximum charging current (6-32A)
- Configure target SOC (50-100%)
- Monitor charger state and current
- Legacy: Traditional throttle response
- Regen: Regenerative braking enabled
- OPD: One Pedal Drive mode
- Regen Zone End: 10-50% (default 16%)
- Coast Zone End: 15-60% (default 17%)
- Regen Progression: 1.0-3.0 (curve aggressiveness)
- Accel Progression: 1.0-3.0 (curve aggressiveness)
- Regen Engage: Time for 0 → negative torque
- Regen Release: Time for negative → 0 torque
- Power Engage: Time for 0 → positive torque
- Power Release: Time for positive → 0 torque
- Crossover: Time for regen ↔ power transitions
- Live view of CAN messages from:
- BMS (0x0F1) - Battery data
- DMC (0x280) - Motor controller
- BSC (0x26A) - DC-DC converter
- NLG (0x728) - Charger
- FreeRTOS task information
- Heap memory usage
- CPU frequency
- System performance metrics
- WiFi Configuration: Change network settings
- Debug Mode: Enable/disable (prevents deep sleep)
- Firmware Info: Chip model, version, uptime
- Configuration Management:
- Export configuration to JSON file
- Import configuration from JSON file
- Factory reset
All configuration is accessible via REST API:
GET /api/status - System status
GET /api/status/live - Real-time vehicle data
GET /api/status/errors - Error log
GET /api/config/driving - Get driving config
POST /api/config/driving - Set driving config
GET /api/config/charging - Get charging config
POST /api/config/charging - Set charging config
GET /api/config/pedal - Get pedal zones
POST /api/config/pedal - Set pedal zones
GET /api/config/transition - Get torque transitions
POST /api/config/transition - Set torque transitions
GET /api/config/limits - Get speed/power limits
POST /api/config/limits - Set limits
POST /api/system/save - Save config to flash
POST /api/system/reset - Factory reset
GET /api/system/export - Download config JSON
POST /api/system/import - Upload config JSON
GET /api/system/info - System information
POST /api/system/debug - Enable/disable debug mode
GET /api/can/messages - Get CAN message data
ws://[IP_ADDRESS]/ws - Real-time data stream (10Hz)
Debug mode prevents the VCU from entering deep sleep, useful for:
- Development and testing
- Keeping WiFi active during extended stops
- Debugging CAN communication issues
Enable via:
- Web interface: System tab → Enable Debug Mode
- API:
POST /api/system/debug {"enabled": true}
- CAN Task (Priority 1, 12KB stack)
- CAN message RX/TX
- Motor speed updates
- Torque calculation
- Temperature monitoring
- 1ms cycle time
-
Control Task (Priority 1, 24KB stack)
- State machine updates
- Interrupt handling
- Performance monitoring
- 50ms cycle time
-
Web Server Task (Priority 1, 16KB stack)
- WiFi management
- HTTP request handling
- WebSocket broadcasts
- 10ms cycle time
- Input validation on all configuration changes
- Automatic fallback to safe defaults
- Error monitoring with severity levels
- System health checks
- CAN timeout detection
- Temperature monitoring
- Voltage/current limits
- Emergency stop capability
- Open web interface
- Navigate to System tab
- Click "Export Configuration"
- Save
vcu_config.jsonfile
- Open web interface
- Navigate to System tab
- Click "Import Configuration"
- Select previously saved JSON file
- SSID:
VCU_XXXXX(XXXXX = chip ID) - Password:
vcu12345 - IP Address:
192.168.4.1
- Configure via web interface System tab
- Automatically falls back to AP if connection fails
- Reconnects automatically if WiFi drops
- Check that AP mode is active (look for
VCU_network) - Default password is
vcu12345 - Try factory reset if needed
- Check IP address in serial monitor
- Ensure device is on same network
- Try clearing browser cache
- Use incognito/private browsing mode
- Click "Save Configuration" button after changes
- Check API response in browser console
- Verify flash storage isn't full
- Check WebSocket connection status (indicator in header)
- Refresh page to reconnect
- Ensure CAN bus is connected and operational
VCU/
├── src/
│ ├── main.cpp - Main application
│ ├── state_manager.cpp - State machine
│ ├── vehicle_control.cpp - Pedal control
│ ├── can_manager.cpp - CAN communication
│ ├── configuration.cpp - Config management
│ ├── wifi_manager.cpp - WiFi management
│ └── web_server.cpp - Web server
├── include/
│ └── [corresponding headers]
├── data/
│ ├── index.html - Main web page
│ ├── styles.css - Styling
│ ├── app.js - API/config logic
│ └── dashboard.js - Charts/live data
├── platformio.ini - Build configuration
└── min_spiffs.csv - Partition table
# Clone repository
git clone [your-repo-url]
cd VCU
# Install dependencies (automatic via PlatformIO)
pio lib install
# Build
pio run
# Upload firmware
pio run --target upload
# Upload web interface
pio run --target uploadfs
# Monitor serial output
pio device monitor[Your License Here]
Built with:
- PlatformIO
- ESP32 Arduino Framework
- ESPAsyncWebServer
- ArduinoJson
- FreeRTOS
For issues, questions, or contributions, please open an issue on GitHub.