Community project

Protected ESP32 Automotive Controller

Photo of Protected ESP32 Automotive Controller
Generated with AI

Ярослав

Published December 3, 2026

This guide builds a protected automotive lighting controller using an ESP32 to drive dual front WS2815 LED strips with real-time responsiveness to vehicle inputs. The design includes galvanic isolation via optocouplers for six protected inputs (brake, turn signals, hazard, and more), a relay driver for switched power management, and a level-shifted data bus to ensure reliable communication with the addressable LEDs.

The project provides a complete wiring diagram, parts list, and modular firmware architecture covering vehicle input handling, power management, animation sequencing, and diagnostics. Assembly steps guide you through safe construction practices, including keeping the vehicle supply disconnected during wiring, verifying power rails before installing the ESP32, and performing a first-light test to confirm all systems are operational.

Wiring diagram

Wiring diagram for Protected ESP32 Automotive Controller
Loading diagram…

Gather all the parts

QtyComponent
1

Left front WS2815 strip, 82 pixels

82 pixels

The 12-volt addressable LED strip inside the left front lamp.

1

Right front WS2815 strip, 82 pixels

82 pixels

The 12-volt addressable LED strip inside the right front lamp.

1

74AHCT125 Quad Buffer / Level Shifter

Quad non-inverting buffer/line driver with 3-state outputs and active-low output-enable pins. In 5 V AHCT/HCT designs, 3.3 V MCU outputs are high enough for the TTL-level inputs, making it a common one-way 3.3 V to 5 V level shifter for WS2812/NeoPixel data and other fast digital lines.

1

AO3400A

30V 5.7A N-channel enhancement-mode logic-level MOSFET in SOT-23-3L. Vgs(th) typically ~0.7V (max 1.45V at Id=250 uA), fully enhanced at Vgs=2.5V-4.5V. RDS(on) ~26 mOhm at Vgs=4.5V, ~38 mOhm at Vgs=2.5V. Driven directly by 3.3V or 5V microcontroller GPIO/PWM as a low-side switch for loads up to its Id and VDS limits. No firmware library required.

1

5 V front-light power relay

A normally-open 5-volt relay that switches power to the front LED converter.

1

Regulated 12 V LED DC/DC converter

An automotive-input converter that supplies a stable 12 volts to the front WS2815 strips.

1

PC817 Optocoupler

Single-channel optocoupler (opto-isolator) in a 4-pin DIP package. Galvanically isolates a low-voltage logic side from a separate circuit by coupling an internal infrared LED to a phototransistor across an insulating gap (isolation voltage ~5 kV). Used to read a higher-voltage signal safely, switch between circuits with different grounds, or shield a microcontroller from a noisy or mains-referenced domain. The input LED needs a series current-limiting resistor (~1 kOhm from a 5 V signal, ~220-330 Ohm from 3.3 V) sized for ~5-20 mA forward current; the output transistor is typically wired open-collector with a pull-up to the MCU side.

1

PC817 Optocoupler

Single-channel optocoupler (opto-isolator) in a 4-pin DIP package. Galvanically isolates a low-voltage logic side from a separate circuit by coupling an internal infrared LED to a phototransistor across an insulating gap (isolation voltage ~5 kV). Used to read a higher-voltage signal safely, switch between circuits with different grounds, or shield a microcontroller from a noisy or mains-referenced domain. The input LED needs a series current-limiting resistor (~1 kOhm from a 5 V signal, ~220-330 Ohm from 3.3 V) sized for ~5-20 mA forward current; the output transistor is typically wired open-collector with a pull-up to the MCU side.

1

PC817 Optocoupler

Single-channel optocoupler (opto-isolator) in a 4-pin DIP package. Galvanically isolates a low-voltage logic side from a separate circuit by coupling an internal infrared LED to a phototransistor across an insulating gap (isolation voltage ~5 kV). Used to read a higher-voltage signal safely, switch between circuits with different grounds, or shield a microcontroller from a noisy or mains-referenced domain. The input LED needs a series current-limiting resistor (~1 kOhm from a 5 V signal, ~220-330 Ohm from 3.3 V) sized for ~5-20 mA forward current; the output transistor is typically wired open-collector with a pull-up to the MCU side.

1

PC817 Optocoupler

Single-channel optocoupler (opto-isolator) in a 4-pin DIP package. Galvanically isolates a low-voltage logic side from a separate circuit by coupling an internal infrared LED to a phototransistor across an insulating gap (isolation voltage ~5 kV). Used to read a higher-voltage signal safely, switch between circuits with different grounds, or shield a microcontroller from a noisy or mains-referenced domain. The input LED needs a series current-limiting resistor (~1 kOhm from a 5 V signal, ~220-330 Ohm from 3.3 V) sized for ~5-20 mA forward current; the output transistor is typically wired open-collector with a pull-up to the MCU side.

1

PC817 Optocoupler

Single-channel optocoupler (opto-isolator) in a 4-pin DIP package. Galvanically isolates a low-voltage logic side from a separate circuit by coupling an internal infrared LED to a phototransistor across an insulating gap (isolation voltage ~5 kV). Used to read a higher-voltage signal safely, switch between circuits with different grounds, or shield a microcontroller from a noisy or mains-referenced domain. The input LED needs a series current-limiting resistor (~1 kOhm from a 5 V signal, ~220-330 Ohm from 3.3 V) sized for ~5-20 mA forward current; the output transistor is typically wired open-collector with a pull-up to the MCU side.

1

PC817C optocoupler for HAZARD input

An optocoupler that safely reads the vehicle hazard-light signal on the input-only GPIO34.

Assemble it in 6 steps

1. Keep the vehicle supply disconnected while wiring

Build and test the controller on a fused 12-volt bench supply first. Do not connect the PCB to the car battery while fitting parts or checking continuity.

  • Set the bench-supply current limit low for the first power-up, then increase it only after checking that the 5-volt and regulated 12-volt rails are correct.
  • A vehicle battery can supply enough current to melt a misplaced wire or damage the board.

2. Wire the two front LED strips

Connect the left strip +12V to the fused regulated 12-volt front-light output (power), its GND to the common ground return (ground), and its DIN to buffer output 1 through the planned 330-ohm series resistor (data). Connect the right strip +12V to its own fused regulated 12-volt output (power), its GND to the common ground return (ground), and its DIN to buffer output 2 through its 330-ohm resistor (data).

  • Run each DATA wire beside a ground wire, and put the 1000-microfarad capacitor physically close to the power entry of each strip.
  • Do not swap +12V and GND on a strip — reversed power can permanently damage the LEDs.

3. Wire the data buffer and relay driver

Connect the 74AHCT125 VCC to 5V (power) and GND to GND (ground). Connect GPIO18 to 1A (left data signal), GPIO19 to 2A (right data signal), and tie 1OE and 2OE to GND so those outputs are enabled. Connect GPIO23 through the planned 220-ohm resistor to the AO3400A gate (signal), its source to GND (ground), and its drain to the relay coil negative terminal (switching return). Connect the other relay-coil terminal to 5V (power).

  • Fit the 100-kilohm resistor between the AO3400A gate and GND so the relay stays off while the ESP32 starts.
  • Fit the flyback diode across the relay coil with its striped end on +5V; reversing it creates a short when the relay turns on.

4. Wire the six protected vehicle inputs

For each PC817 input, route the named vehicle signal through its protection parts and resistor chain to the optocoupler LED anode: ACC to pc_acc, left turn to pc_left, right turn to pc_right, lock to pc_lock, unlock to pc_unlock, and hazard to pc_hazard. Join each optocoupler emitter to GND (ground), then connect collectors to GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, and GPIO34 respectively (signals). Fit a 10-kilohm pull-up from every collector to ESP32 3V3; GPIO34 especially needs this external pull-up because it has none inside the ESP32.

  • Check each car wire with a meter before connecting it: this Rev.1 input circuit is for a signal that becomes positive, not a signal that is switched to ground.
  • Do not connect a negative-switched LOCK, UNLOCK, or lighting wire to this positive-input circuit without changing that input stage.

5. Check rails before fitting the ESP32

With the ESP32 unplugged, verify 5V at the DevKit supply point (power), verify the LED converter is off while ACC is inactive, then apply ACC and confirm the relay closes and the LED converter output is a stable 12V (power).

  • Only install the DevKit after the measured voltages are correct.
  • More than 5V at the DevKit 5V input can damage the board.

6. Install the ESP32 and perform the first light test

Insert the ESP32 with its USB-C connector accessible. With ACC inactive, both strips should remain dark. Apply ACC: after about a quarter of a second the relay turns on and both lamps enter the daytime-running-light scene. Trigger LEFT, RIGHT, HAZARD, LOCK, and UNLOCK one at a time to test their scenes.

  • Use the USB Serial output to see the input states, relay state, active mode, frame rate, free memory, and reset reason.
  • Keep the first test at the built-in 85% brightness limit and watch the strips, wiring, relay, and converter for unusual heat.

Review all connections

1. Connections between "data_buffer" and "ESP32"

Functiondata_bufferESP32
powerVCC5V
groundGNDGND
digital1AGPIO 18
digital1Y → Left front WS2815 strip, 82 pixels DINEXT
ground1OEGND
digital2AGPIO 19
digital2Y → Right front WS2815 strip, 82 pixels DINEXT
ground2OEGND
ground3AGND
power3OE5V
ground4AGND
power4OE5V

2. Connections between "front_relay_driver" and "ESP32"

Functionfront_relay_driverESP32
digitalGate (G)GPIO 23
groundSource (S)GND
powerDrain (D) → 5 V front-light power relay COIL-EXT

3. Connections between "front_relay" and "ESP32"

Functionfront_relayESP32
powerCOIL+5V
powerCOMVIN
powerNO → Regulated 12 V LED DC/DC converter VIN+EXT

4. Connections between "front_led_dcdc" and "ESP32"

Functionfront_led_dcdcESP32
groundGNDGND
powerVOUT+ → Left front WS2815 strip, 82 pixels +12VEXT
powerVOUT+ → Right front WS2815 strip, 82 pixels +12VEXT

5. Connections between "front_left_ws2815" and "ESP32"

Functionfront_left_ws2815ESP32
groundGNDGND

6. Connections between "front_right_ws2815" and "ESP32"

Functionfront_right_ws2815ESP32
groundGNDGND

7. Connections between "pc_acc" and "ESP32"

Functionpc_accESP32
digitalCollectorGPIO 25
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal ACC+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT

8. Connections between "pc_left" and "ESP32"

Functionpc_leftESP32
digitalCollectorGPIO 26
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal turn-L+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT

9. Connections between "pc_right" and "ESP32"

Functionpc_rightESP32
digitalCollectorGPIO 27
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal turn-R+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT

10. Connections between "pc_lock" and "ESP32"

Functionpc_lockESP32
digitalCollectorGPIO 32
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal lock+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT

11. Connections between "pc_unlock" and "ESP32"

Functionpc_unlockESP32
digitalCollectorGPIO 33
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal unlock+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT

12. Connections between "pc_hazard" and "ESP32"

Functionpc_hazardESP32
groundEmitterGND
digitalAnode → J4 vehicle-harness terminal hazard+EXT
groundCathode → J4 vehicle-harness terminal signal-returnEXT
analogCollectorGPIO 34

Deploy the firmware

#include <Arduino.h>
#include "VehicleInputs.h"
#include "PowerManager.h"
#include "LightingController.h"
#include "AnimationManager.h"
#include "Renderer.h"
#include "Diagnostics.h"
#include "Settings.h"

VehicleInputs inputs;
PowerManager power;
AnimationManager animations;
Renderer renderer;
LightingController lighting;
Diagnostics diagnostics;
Settings settings;

void setup() {
  inputs.begin();
  power.begin();
  animations.begin();
  renderer.begin();
  lighting.begin();
  settings.begin();
  diagnostics.begin();
}

void loop() {
  const uint32_t now = millis();
  inputs.update(now);
  power.update(now, inputs);
  animations.update(now);
  lighting.update(now, inputs, power, animations, renderer);
  diagnostics.update(now, inputs, power, lighting);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik