
SensorECU
Alex-Livson/distributed-electric-vehicle-platform
A small-scale electric vehicle electronics platform built around three custom ESP32-based ECUs and a Raspberry Pi 4 supervisory controller, connected through a 500 kbps CAN network.

A small-scale electric vehicle electronics platform built around three custom ESP32-based ECUs and a Raspberry Pi 4 supervisory controller, connected through a 500 kbps CAN network.
MotorECU is an open-source printed circuit board by Alex-Livson, from the Alex-Livson/distributed-electric-vehicle-platform repository on GitHub. It is a 2-layer board of 84.4 × 78.4 mm with 21 parts on 39 nets, routed with 83 tracks and 1 via.
It is built around the SN65HVD230D. Its parts include 3 capacitors, 1 resistor and 1 diode.
A small-scale electric vehicle electronics platform built around three custom ESP32-based ECUs and a Raspberry Pi 4 supervisory controller, connected through a 500 kbps CAN network.
The project was built as a hands-on study of automotive embedded systems, custom PCB design, distributed vehicle electronics, safety-oriented control, Raspberry Pi development, and computer vision.

The demonstration includes manual driving, RFID authorization, assisted collision protection, live vehicle telemetry, and OpenCV-assisted autonomous obstacle avoidance.
The vehicle uses a distributed control architecture similar in concept to a simplified electric vehicle.
Instead of one microcontroller handling the entire system, responsibilities are divided between several networked controllers:
All four nodes communicate over a shared 500 kbps CAN bus.
The architecture separates sensing, power monitoring, motor actuation, and higher-level decision making.
Raspberry Pi 4
Supervisory Vehicle Computer
│
│
500 kbps CAN Bus
│
┌───────────────────┼───────────────────┐
│ │ │
Battery ECU Sensor ECU Motor ECU
│ │ │
INA228 + NTC Ultrasonic / IMU TB6612FNG
RFID Dual TT Motors
OLED Displays
LED MatrixThe Raspberry Pi receives telemetry from each ECU, applies supervisory safety rules, and transmits the final motor commands to the vehicle.
The electronics were first validated on breadboards and then converted into three custom two-layer PCBs.

The Battery ECU monitors the electrical health of the complete vehicle.
Hardware includes:
The INA228 is positioned near the beginning of the vehicle power path so current measurement represents the entire system.
The Sensor ECU manages most of the vehicle's environmental sensing and local user interface.
It controls:
The ultrasonic sensor continuously provides forward and directional range data used by both the safety system and autonomous driving logic.
The Motor ECU controls two TT gearmotors through a TB6612FNG dual motor driver.
Commands are transmitted as independent signed left and right motor percentages, allowing:
The ECU also reports motor status back to the Raspberry Pi over CAN.
All three ECU boards were designed in KiCad.
The PCB development process included:
Typical trace widths were approximately:
The bottom layer was used primarily as a ground plane.
The completed vehicle contains four CAN nodes operating at 500 kbps.
The Battery ECU and Raspberry Pi are located at the two ends of the physical bus and provide termination.
A powered-off measurement across CAN-H and CAN-L is approximately 60 Ω, corresponding to two effective 120 Ω terminating resistors.
| CAN ID | Direction | Purpose |
|---|---|---|
0x100 | Battery ECU → Pi | Battery voltage, current, and temperature |
0x200 | Sensor ECU → Pi | Sensor status, ultrasonic range, RFID state |
0x201 | Sensor ECU → Pi | Accelerometer X/Y/Z |
0x202 | Sensor ECU → Pi | Angular velocity X/Y/Z |
0x203 | Sensor ECU → Pi | Roll, pitch, and yaw |
0x204 | Sensor ECU → Pi | Left, center, and right ultrasonic ranges |
0x300 | Motor ECU → Pi | Motor output and ECU status |
0x400 | Pi → Vehicle | Drive command, mode, speed limit, and safety state |
0x401 | Pi → Sensor ECU | Lock/unlock request |
Detailed CAN payload definitions are available in the full engineering report.
The vehicle computer is a Raspberry Pi 4 Model B with 1 GB RAM running Raspberry Pi OS Lite.
The main controller is written in Python and integrates:
The Pi runs a supervisory control loop every 20 ms, corresponding to approximately 50 Hz.
CAN and the main vehicle application are configured to initialize automatically when the Raspberry Pi boots.

The Raspberry Pi hosts a local browser-based vehicle interface.
The dashboard displays:
Manual and Assisted driving are controlled using WASD, with an adjustable 0–100% speed limit.
Manual mode gives the driver direct WASD control over the differential drive system.
A forward collision stop remains active even in Manual mode so the vehicle cannot continue driving directly into a very close obstacle during testing.
Assisted mode keeps manual WASD control while adding distance-based collision protection.
| Forward Distance | Vehicle Response |
|---|---|
| Greater than 40 cm | Normal requested output |
| 20–40 cm | Forward output progressively reduced |
| 12–20 cm | Positive forward commands removed |
| Less than 12 cm | Hard forward collision intervention |
This allows the driver to remain in control while the supervisory system limits unsafe commands.
Autonomous mode combines ultrasonic ranging and OpenCV computer vision.
The ultrasonic sensor determines when an obstacle is physically close.
When an obstacle requires avoidance, OpenCV evaluates the left and right portions of the camera image to estimate which side appears less obstructed.
The vehicle then:
If the camera result is unavailable or nearly tied, the vehicle falls back to the left/right ultrasonic scan.
The system is intended as vision-assisted obstacle avoidance, rather than full autonomous driving or localization.
The OpenCV pipeline processes the lower portion of the forward camera image.
Processing includes:
The lower portion of each image region is weighted more heavily because it is more likely to contain obstacles in the vehicle's immediate path.
All requested motor commands pass through a supervisory safety manager before being transmitted to the Motor ECU.
| Protection | Behavior |
|---|---|
| RFID authorization | Blocks vehicle movement while locked |
| Emergency stop | Overrides all drive modes |
| Browser watchdog | Stops Manual/Assisted control after 500 ms without fresh input |
| Battery ECU timeout | Blocks motion if critical battery telemetry becomes stale |
| Sensor ECU timeout | Blocks motion if critical sensor telemetry becomes stale |
| Wall protection | Slows or stops forward movement near obstacles |
| Current warning | Reduces motor output above 4.75 A |
| Current limiting | Stronger output reduction above 5.25 A |
| Overcurrent shutdown | Stops vehicle above 5.50 A and applies a 1.5 s cooldown |
The system follows a fail-safe principle: if the controller does not have enough current information to determine that movement is safe, the preferred state is no movement.
| Metric | Result |
|---|---|
| CAN bitrate | 500 kbps |
| Pi supervisory loop | 50 Hz |
| Local browser control latency | ~20–30 ms |
| Idle current | ~0.8–0.9 A |
| Typical driving current | ~1.2–1.3 A |
| Peak observed current | ~1.6 A |
| Battery runtime | ~1 hour |
| Battery | 2S 7.4 V, 2000 mAh |
| Vehicle dimensions | 24 × 19 × 19 cm |
| Vehicle mass | ~872 g including battery |
| Estimated maximum speed | ~4 ft/s |
| Approximate project cost | ~$300 |
Maximum physical speed is estimated rather than encoder-measured because the current prototype does not contain wheel encoders.
A complete engineering report documents the project architecture, PCB development, electrical system, CAN protocol, software, safety design, debugging process, validation, and future improvements.
Read the full Engineering Report (download pdf!)
The project was developed between July 11 and August 17, 2026.
I designed the system architecture, defined the ECU responsibilities and CAN protocol, created all three PCB schematics and layouts, assembled and soldered the boards, integrated the vehicle electronics, and performed final system testing.
The project uses standard hardware and software libraries for common peripheral interfaces and software functionality. Development also included external code review and troubleshooting assistance.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 2 | 0.1uF | LGARI:0.1 Ceramic Capacitor | C1, C3 |
| 2 | Motor_DC | LGARI:DC_Motor | M1, M2 |
| 1 | 330 | LGARI:Resistor | R1 |
| 1 | 470uF | LGARI:Elytrolytic Capacitor | C2 |
| 1 | Buck Converter | LGARI:Buck Converter | Buck |
| 1 | Buzzer | Buzzer_Beeper:Buzzer_12x9.5RM7.6 | BZ1 |
| 1 | JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical | Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical | PWR IN |
| 1 | LED | LGARI:LED | D1 |
| 1 | SN65HVD230 | LGARI:SN65HVD230 CAN Module | CAN |
| 1 | TB6612FNG | LGARI:TB6612FNG DC Motor Driver | Driver |
| 1 | ~ | PCM_ESP32_Footprints:ESP32_30pin | ESP32 |
The 13 most common of 21 parts.

Alex-Livson/distributed-electric-vehicle-platform
A small-scale electric vehicle electronics platform built around three custom ESP32-based ECUs and a Raspberry Pi 4 supervisory controller, connected through a 500 kbps CAN network.

Alex-Livson/distributed-electric-vehicle-platform
A small-scale electric vehicle electronics platform built around three custom ESP32-based ECUs and a Raspberry Pi 4 supervisory controller, connected through a 500 kbps CAN network.

menloresearch/asimov-1
v1 of Asimov, an open-source humanoid robot

tenderlove/initial-v
It's a BMW shifter converted to a Bluetooth Keyboard that you use with Vim



hirakuni45/RX
Renesas RX Microcontroller, C++ framework, Library, Sample

henrikssn/TurboCAN
This is the official repository for the TurboCAN controller board, designed specifically for the Voron AfterBurner toolhead but can also be used on similar toolheads using NEMA17 steppers.

VIPQualityPost/lemon-pepper-stepper
simplefoc all-in-one 50W hybrid stepper + bldc driver

luftaquila/monolith
DIY wireless real-time datalogging platform for Student Formula and Baja.
It measures 84.4 × 78.4 mm and has 2 copper layers, 1.6 mm thick.
21 parts, built around the SN65HVD230D. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the Alex-Livson/distributed-electric-vehicle-platform repository on GitHub, at the commit this page was made from: the board is pcb/MotorECU/MotorECU.kicad_pcb and its schematic pcb/BatteryECU/BatteryECU.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask Alex-Livson before reusing the design.