Files
arduino_gauge_controller/wiring.md
Adrian A. Baumann 8bdae1da9b Update docs and firmware for ESPHome bridge migration
- Replace gauge.py (MicroPython) references with gaugecontroller.yaml (ESPHome)
- Update CLAUDE.md and README.md to document ESPHome-native API integration
- Update LED wiring docs for separate main/indicator strips (D22/D36)
- Refactor Arduino firmware to drive two WS2812 strips independently
- Add per-gauge physical offset caching for main and indicator LEDs
- Frame-limit breathe effect (16ms) to reduce unnecessary strip refreshes
2026-04-29 19:03:22 +02:00

7.4 KiB

Wiring

This document describes the wiring required for the current integrated system:

  • Arduino Mega 2560
  • HV5812P VFD driver
  • 4-digit VFD tube with decimal point and alarm bell
  • 3 stepper-driven gauges
  • WS2812B LEDs
  • ESP32 running gauge.py as the MQTT / Home Assistant bridge

It is intentionally based on the code that is in the repository now:

System Power

You effectively have three power domains:

  1. 5V logic for the Arduino Mega logic, the HV5812 logic side, and usually the step/dir logic inputs
  2. high voltage for the VFD for HV5812P VPP and the VFD segment/grid drive
  3. motor / actuator power for the stepper gauges and their driver hardware

Minimum common rule:

  • all logic grounds must be common

That means these must share GND:

  • Arduino Mega GND
  • ESP32 GND
  • HV5812P logic GND
  • stepper driver logic GND
  • WS2812B GND

The VFD high-voltage supply still references the same ground, but its high-voltage nodes must never be connected directly to Arduino or ESP32 GPIO pins.

Arduino Mega 2560

Use the Mega as the central logic controller.

Power:

  • Mega 5V <- regulated 5V logic supply
  • Mega GND <- common logic ground

Serial bridge to ESP32:

  • Mega RX1 pin 19 <- ESP32 TX GPIO 17
  • Mega TX1 pin 18 -> voltage divider -> ESP32 RX GPIO 16
  • Mega GND <-> ESP32 GND

This matches the current code:

Because the Mega transmits 5V logic and the ESP32 expects 3.3V logic on RX, add a resistor divider on the Mega TX1 -> ESP32 RX line.

Suggested simple divider:

  • Mega TX1 -> 1 kOhm resistor -> divider node
  • divider node -> 2 kOhm resistor -> GND
  • divider node -> ESP32 GPIO16 (RX)

That scales the Mega's 5V TX signal to roughly 3.3V for the ESP32 RX input.

VFD Control: Mega -> HV5812P

These are the integrated pin assignments used by the merged controller:

Mega Pin HV5812P Signal Purpose
D46 DATA IN / DIN serial data into HV5812P
D47 CLOCK / CLK shift clock
D48 STROBE / LATCH latch transfer
D49 BLANKING / OE output blanking
5V VDD HV5812 logic supply
GND GND common reference
VFD HV+ VPP HV5812 high-voltage rail

Important:

  • VDD is the low-voltage logic rail
  • VPP is the high-voltage output rail
  • do not connect Arduino 5V to VPP

HV5812P -> VFD Tube

The current output map is:

HV5812 Output Tube Function
HVOut1 segment A
HVOut2 segment B
HVOut3 segment C
HVOut4 segment D
HVOut5 segment E
HVOut6 segment F
HVOut7 segment G
HVOut8 decimal point segment
HVOut9 alarm bell segment
HVOut10 digit grid 1
HVOut11 digit grid 2
HVOut12 digit grid 3
HVOut13 digit grid 4
HVOut14 indicator grid between digits 2 and 3

Logical segment layout:

 ---A---
|       |
F       B
|---G---|
E       C
|       |
 ---D---

Additional VFD wiring notes:

  • the VFD filament/heater wiring is separate from the HV5812 outputs
  • the exact filament supply depends on your tube
  • the HV5812 only drives the segments and grids

Gauge Control Pins

The current sketch drives three gauges.

Each gauge needs a driver or actuator input that accepts:

  • DIR
  • STEP
  • optionally ENABLE if you later add one in code

Current assignments:

Gauge Mega DIR Mega STEP
Gauge 0 D50 D51
Gauge 1 D8 D9
Gauge 2 D52 D53

Connect each pair to the matching stepper driver inputs.

Example:

  • Mega D50 -> Gauge 0 driver DIR
  • Mega D51 -> Gauge 0 driver STEP
  • Mega D8 -> Gauge 1 driver DIR
  • Mega D9 -> Gauge 1 driver STEP
  • Mega D52 -> Gauge 2 driver DIR
  • Mega D53 -> Gauge 2 driver STEP

Also connect:

  • Mega GND -> each driver logic ground

If your driver boards need separate motor power, supply that from the proper motor supply. Do not power motors from the Mega 5V pin.

WS2812 LED Strips

The current sketch expects two LED data chains. Backlight and status LEDs stay on the main strip; the red/green dial indicator LEDs are on their own strip.

Mega Pin LED Strip
D22 main backlight/status DIN
D36 indicator DIN
5V both strips 5V
GND both strips GND

Notes:

  • the command protocol still exposes 7 LEDs per gauge
  • logical indices 0-2 are backlight, 3-4 are indicators, and 5-6 are status
  • use a proper 5V supply sized for the LED current
  • keep LED ground common with the Mega

If the strip is powered from a separate 5V supply:

  • connect external 5V -> LED 5V
  • connect external GND -> LED GND
  • connect that same GND to Mega GND

ESP32 Bridge

The ESP32 runs gauge.py and talks to the Mega over UART and to Home Assistant over MQTT/Wi-Fi.

ESP32 to Mega:

ESP32 Pin Mega Pin Purpose
GPIO17 RX1 pin 19 ESP32 TX -> Mega RX
GPIO16 TX1 pin 18 ESP32 RX <- Mega TX
GND GND common ground

ESP32 power:

  • power the ESP32 from a proper 3.3V or board-supported USB/5V input, depending on your board
  • do not feed raw 5V into a bare 3.3V ESP32 module unless the board has its own regulator

One-Page Wiring Summary

Power

  • 5V logic supply -> Mega 5V
  • 5V logic supply -> HV5812 VDD
  • 5V logic supply -> WS2812B 5V
  • motor supply -> gauge driver motor power inputs
  • VFD high-voltage supply -> HV5812 VPP
  • all grounds common

Mega to ESP32

  • Mega 19 (RX1) <- ESP32 GPIO17 (TX)
  • Mega 18 (TX1) -> resistor divider -> ESP32 GPIO16 (RX)
  • Mega GND <-> ESP32 GND

Resistor divider on Mega TX1:

  • Mega TX1 -> 1 kOhm -> divider node
  • divider node -> ESP32 GPIO16
  • divider node -> 2 kOhm -> GND

Mega to HV5812

  • D46 -> DIN
  • D47 -> CLK
  • D48 -> STROBE
  • D49 -> BLANKING
  • 5V -> VDD
  • GND -> GND
  • VFD HV+ -> VPP

HV5812 to Tube

  • HVOut1..7 -> segments A..G
  • HVOut8 -> decimal point
  • HVOut9 -> alarm bell
  • HVOut10..13 -> digit grids 1..4
  • HVOut14 -> indicator grid

Mega to Gauges

  • D50/D51 -> gauge 0 DIR/STEP
  • D8/D9 -> gauge 1 DIR/STEP
  • D52/D53 -> gauge 2 DIR/STEP

Mega to LEDs

  • D22 -> WS2812B DIN
  • 5V -> WS2812B 5V
  • GND -> WS2812B GND

Sanity Checklist Before Power-On

  • Mega, ESP32, HV5812 logic, LED strip, and driver logic grounds are all common
  • Mega D46-D49 go to the HV5812, not to the gauge drivers
  • Mega D50-D53 and D8-D9 go only to the gauge drivers
  • HV5812 VDD is 5V
  • HV5812 VPP is the VFD high-voltage rail, not 5V
  • ESP32 UART is crossed correctly: TX -> RX, RX -> TX
  • WS2812B has its own adequate 5V supply if current draw is significant
  • motor power is not coming from the Mega

What This Does Not Define

This document does not define:

  • the exact VFD filament supply voltage/current
  • the exact motor driver board power pins, because that depends on the driver hardware you are using
  • the physical PDIP package pin numbers of the HV5812P