Firmware for STM32-based control of Tesla 3-way water valves, coolant pumps, and other automotive peripherals.
Originally developed for integration with the Zombie VCU, this project supports analog and digital IO, CAN communication, and ESP8266-based terminal access.
- Tesla 3-way coolant valve
- Coolant pump with RPM control (manual or auto mode)
- Vacuum pump with hysteresis and warning detection (active only in Ready state)
- Voltage divider for analog signal monitoring
- Digital IO pins for output control and sensor reading
include/ Header files
src/ Source files
libopeninv/ External library for control logic
libopencm3/ Submodule for low-level STM32 hardware access
Makefile Build system
linker.ld STM32 linker script
.gitpod.yml Gitpod workspace configuration
project.cbp Code::Blocks project file
You will need the arm-none-eabi toolchain.
sudo apt-get install git gcc-arm-none-eabiThe only external dependencies are:
Fetch and build them with:
make get-depsBuild the stm32_yourname firmware binary:
makeOutput files:
stm32_yourname.elfstm32_yourname.hexstm32_yourname.bin
These can be uploaded to your board via JTAG, updater.py script, or ESP8266 web interface.
Flash the firmware using OpenOCD:
make flashEnsure your OpenOCD configuration uses:
parport.cfgas flasher interfaceolimex_stm32_h103.cfgfor the board
The firmware includes a terminal accessible over USART3 or via ESP8266.
set,get,flag,stream— Parameter interactionjson— JSON format exportsave,load,defaults— Flash parameter handlingreset,serial,errors,help— System and debug tools
| Pin | Function | HW/SW Interface | Description | Code Reference |
|---|---|---|---|---|
| 01 | RS232 Rx | RS232 receive line | ||
| 02 | RS232 Tx | RS232 transmit line | ||
| 03 | GP Out 3 | PD13 | Low-side switch (NCV8402ASTT1G) — Sinks to GND via N-MOSFET, 1k pull-up to 12V | DigIo::tesla_coolant_valve_1_out right |
| 04 | GP Out 2 | PD14 | Same as above | DigIo::tesla_coolant_valve_2_out left |
| 05 | PWM 3 | PB0 | High-side PWM (FAN3122TMX), 12V-level compatible | |
| 06 | PWM 2 | PA7 | High-side PWM (FAN3122TMX), 12V-level compatible | DigIo::eps_quick_spoolup_out |
| 07 | PWM 1 | PA6 | High-side PWM (FAN3122TMX), 12V-level compatible | DigIo::eps_ignition_on_out |
| 08 | Analog 2 in | PC3 | 5V tolerant analog input, clamped to 3.3V, protected by resistor & diode | AnaIn::pag_hot_cool_flap |
| 09 | Analog 1 in | PC2 | Same as above | |
| 10 | DAC 2 | PA5 | Buffered via op-amp (TDA2320A), filtered output | |
| 11 | DAC 1 | PA4 | Same as above | |
| 12 | MG2 Temp - | Temperature sensor input | ||
| 13 | MG2 Temp + | Temperature sensor input | ||
| 14 | MG1 Temp - | Temperature sensor input | ||
| 15 | Ignition T15 In | PD6 | 12V digital input, protected with voltage divider + cap | DigIo::ignition_in |
| 16 | REQ- | |||
| 17 | REQ+ | |||
| 18 | CLK- | |||
| 19 | CLK+ | |||
| 20 | MTH- | |||
| 21 | MTH+ | |||
| 22 | HTM- | |||
| 23 | HTM+ | |||
| 24 | LIN | |||
| 25 | CAN EXT 3 L | |||
| 26 | CAN EXT 3 H | |||
| 27 | CAN EXT L | BMS-CAN; DCDC-CAN |
||
| 28 | CAN EXT H | BMS-CAN; DCDC-CAN |
||
| 29 | MG1 Temp + | Temperature sensor input | ||
| 30 | Oil Pump PWM | PE9 | 12V PWM via MMBT3904 NPN transistor | |
| 31 | Neg Contactor LS Switch | PD15 | Low-side switch (NCV8402ASTT1G) | DigIo::tesla_coolant_pump_out |
| 32 | Inverter Power LS Switch | PA8 | Low-side switch (NCV8402ASTT1G) | DigIo::ready_out |
| 33 | Main Contactor LS Switch | PC7 | Low-side switch (NCV8402ASTT1G) | DigIo::condition_out |
| 34 | Precharge LS Switch | PC6 | Low-side switch (NCV8402ASTT1G) | DigIo::heater_contactor_out |
| 35 | Pot 2 | Digital potentiometer (AD5227BRJZ50-R2), SPI controlled, 0.1μF filtered | ||
| 36 | Pot 1 | Same as above | ||
| 37 | Trans SP | PD12 | Protected HS switch (NCV8461DR2G) with diagnostics | DigIo::VCU_out |
| 38 | Trans SL2- | PC8 | Low-side switch (NCV8402ASTT1G) | |
| 39 | Trans SL1- | PC9 | Same as above | DigIo::vacuum_pump_out |
| 40 | Trans PB3 | |||
| 41 | Trans PB2 | |||
| 42 | Trans PB1 | |||
| 43 | CAN EXT 2 L | Charger-CAN |
||
| 44 | CAN EXT 2 H | Charger-CAN |
||
| 45 | Throttle Ground | |||
| 46 | Throttle 2 | PC1 | 5V tolerant analog input, clamped & protected - 3.9k series resistor only 5V! | AnaIn::tesla_coolant_valve_2_in left |
| 47 | Throttle 1 | PC0 | 5V tolerant analog input, clamped & protected - 3.9k series resistor only 5V! | AnaIn::tesla_coolant_valve_1_in right |
| 48 | +5V Throttle | |||
| 49 | Brake Input | PA15 | 12V digital input, protected | DigIo::ready_safety_in |
| 50 | GP12V Input | PD4 | 12V digital input, protected | DigIo::vacuum_sensor_in |
| 51 | Hvrequest | PD5 | 12V digital input, protected | DigIo::heater_contactor_feedback_in |
| 52 | Start | PD7 | 12V digital input, protected | DigIo::heater_thermal_switch_in |
| 53 | Reverse Direction | PB3 | 12V digital input, protected | |
| 54 | Forward Direction | PB4 | 12V digital input, protected | |
| 55 | Ground | |||
| 56 | Permanent +12V | |||
| Int | 12V Supply Measurement | PB1 | Voltage divider (8.2k/1.8k), filtered to scale to ADC | AnaIn::dc_power_supply |
| Int | Status LED | PE2 | Push-pull output, 680Ω to GND | DigIo::led_out |
+12V
|
[FUSE_sVCU]
|
[Contactor Feedback SW]-----> Feedback Input
+12V
|
[FUSE_heater]
|
[Thermal Switch 65°C]-----> Thermo Switch Input
|
Contactor +
|
[Heater Contactor]
|
Contactor -
|
LS Switch Output (to GND)
This project is licensed under the GNU General Public License v3.
See LICENSE for full terms.
Based on the stm32-template by Johannes Huebner.
Extended for Zombie VCU use cases and embedded control.