CAN-controlled 8-channel PWM power distribution module for vehicle lighting and accessory control with OTA firmware update capability.
- Microcontroller: ESP32 (WROOM32)
- Function: 8-channel PWM lighting/accessory controller with CAN bus interface
- Key Features:
- 8 independent MOSFET-driven PWM outputs (0-255 brightness)
- CAN bus communication at 500 kbps
- Individual and master on/off/brightness control
- Animated light sequences (startup, interior, exterior)
- Over-the-air (OTA) firmware updates via WiFi
- WiFi credentials provisioned dynamically over CAN bus
- Hierarchical PCB schematic design (5 sheets)
- Microcontroller: ESP32 development board
- CAN Transceiver: Vehicle CAN bus interface (TX: GPIO 15, RX: GPIO 13)
- MOSFET Drivers: 8 channels for PWM output switching
- DIP Switches: Configuration switches
PWM Outputs:
| GPIO | Function |
|---|---|
| 32 | Output 1 |
| 33 | Output 2 |
| 26 | Output 3 |
| 14 | Output 4 |
| 4 | Output 5 |
| 17 | Output 6 |
| 19 | Output 7 |
| 23 | Output 8 |
This project uses the consolidated TrailCurrentKiCADLibraries.
Setup:
# Clone the library
git clone git@github.com:trailcurrentoss/TrailCurrentKiCADLibraries.git
# Set environment variables (add to ~/.bashrc or ~/.zshrc)
export TRAILCURRENT_SYMBOL_DIR="/path/to/TrailCurrentKiCADLibraries/symbols"
export TRAILCURRENT_FOOTPRINT_DIR="/path/to/TrailCurrentKiCADLibraries/footprints"
export TRAILCURRENT_3DMODEL_DIR="/path/to/TrailCurrentKiCADLibraries/3d_models"See KICAD_ENVIRONMENT_SETUP.md in the library repository for detailed setup instructions.
- Set up environment variables (see Library Dependencies above)
- Open KiCAD:
kicad EDA/trailer-power-control-system.kicad_pro
- Verify libraries load - All symbol and footprint libraries should resolve without errors
- View 3D models - Open PCB and press
Alt+3to view the 3D visualization
The design uses a hierarchical schematic with dedicated sheets:
- Root - Top-level connections
- Power - Power distribution and regulation
- CAN - CAN bus transceiver interface
- MCU - ESP32 microcontroller and support circuits
- MOSFETs - 8-channel MOSFET driver outputs
- DIP Switch - Configuration switches
See src/ directory for PlatformIO-based firmware.
Setup:
# Install PlatformIO (if not already installed)
pip install platformio
# Build firmware
pio run
# Upload to board (serial)
pio run -t upload
# Upload via OTA (after initial flash)
pio run -t upload --upload-port esp32-DEVICE_IDThis firmware depends on the following public libraries:
- OtaUpdateLibraryWROOM32 (v0.0.1) - Over-the-air firmware update functionality
- TwaiTaskBasedLibraryWROOM32 (v0.0.1) - CAN bus communication interface
All dependencies are automatically resolved by PlatformIO during the build process.
WiFi Credentials:
- WiFi credentials are provisioned dynamically via CAN bus (Message ID 0x01)
- Credentials are stored in NVS (non-volatile storage) and persist across reboots
- For standalone testing, credentials can be set manually in firmware
Receive (Bus to Module):
| CAN ID | Description |
|---|---|
| 0x00 | OTA update trigger (MAC-based device targeting) |
| 0x01 | WiFi credential provisioning (SSID/password via CAN) |
| 0x18 | Toggle channel on/off (byte 0 = channel 0-7, 8=all on, 9=all off) |
| 0x21 | Set brightness (byte 0 = channel, byte 1 = PWM value 0-255) |
| 0x1E | Trigger light sequence (interior/exterior animations) |
Transmit (Module to Bus):
| CAN ID | Description |
|---|---|
| 0x1B | Status report - current PWM values for all 8 channels (8 bytes) |
- PCB Files: Ready for fabrication via standard PCB services (JLCPCB, OSH Park, etc.)
- BOM Generation: Export BOM from KiCAD schematic (Tools > Generate BOM)
- JLCPCB Assembly: See BOM_ASSEMBLY_WORKFLOW.md for detailed assembly workflow
├── EDA/ # KiCAD hardware design files
│ ├── trailer-power-control-system.kicad_pro
│ ├── trailer-power-control-system.kicad_sch # Root schematic
│ ├── can.kicad_sch # CAN subsystem
│ ├── mcu.kicad_sch # MCU subsystem
│ ├── power.kicad_sch # Power subsystem
│ ├── mosfets.kicad_sch # 8-channel MOSFET drivers
│ ├── dip_switch.kicad_sch # Configuration switches
│ └── trailer-power-control-system.kicad_pcb # PCB layout
├── src/ # Firmware source
│ ├── main.cpp # Main application
│ ├── globals.h # Pin definitions and debug macros
│ ├── canHelper.h # CAN message handling (408 lines)
│ ├── lightSequences.h # Startup and animated light sequences
│ ├── wifiConfig.h # NVS WiFi credential storage
│ └── debug.h # Debug macros
├── data/
│ └── partitions.csv # ESP32 flash partition layout
└── platformio.ini # Build configuration
MIT License - See LICENSE file for details.
This is open source hardware. You are free to use, modify, and distribute these designs under the terms of the MIT license.
Improvements and contributions are welcome! Please submit issues or pull requests.
For questions about:
- KiCAD setup: See KICAD_ENVIRONMENT_SETUP.md
- Assembly workflow: See BOM_ASSEMBLY_WORKFLOW.md