--- type: concept tags: [hardware, patrol, outputs, ch422g, wiring, relay, reverse] updated: 2026-10-28 --- # Reverse lights from the board (DO0) The Patrol's reverse lamps have no signal of their own after the swap; the gear lever position is on the bus (`0x1D2` byte 0, `(verified)` → [[can-id-candidates]]). The Main CTRL lights them through a 12 V relay on its isolated output **DO0** whenever the lever is in **R** (user request, 2026-10-28). ## The output circuit `(source: [[esp32-s3-touch-lcd-5-schematic]], sheet 1 "DI/DO", read from the PDF text)` - CH422G **OC0** (pin 8) → R24 100 Ω → PC817 (T1) LED, anode via R74 510 Ω to 3V3. **OC0 LOW = LED on.** - PC817 phototransistor → R58 1 kΩ → base of NPN power transistor T2 (R60 10 kΩ base pull-down). T2 collector = terminal **`DOUT0`** (silkscreen `DO0`), **emitter = board GND**, C102 100 nF across. - DO1 is the same circuit on OC1 / T3 / T4 / `DOUT1`. - Waveshare's rating: 5–36 V, **450 mA sink per channel** (source: [[esp32-s3-touch-lcd-5b-waveshare-wiki]]). The transistor's part number is not readable in the schematic text `(unverified)`. > [!warning] "Isolated" only between the expander and the transistor > There is no `DO_COM` terminal: the load current flows out of DO0 into the board's **GND**. The optocoupler isolates the CH422G from the output transistor, not the output from the board's ground. Fine here, because the board already shares vehicle ground for CAN and for the diff-lock inputs — but never return the relay current anywhere but the board's `GND`/vehicle ground. The chip powers up with OC0 high (LED off), and the panel library writes that default again at every display init `(source: ESP32_IO_Expander, esp_io_expander_ch422g.c reset())`, so the lamps are off from reset until the firmware decides otherwise. ## Wiring | Relay pin (ISO mini relay) | Connect to | |---|---| | 86 (coil +) | +12 V — the same supply that feeds the board's `VIN` (switched with the ignition is best) | | 85 (coil −) | **`DO0`** | | flyback diode (1N4007 or similar) | across 85/86, cathode (stripe) on the +12 V side | | 30 / 87 | the reverse-lamp feed, as the lamp circuit needs | - A standard 30 A mini relay coil is 70–90 Ω → 130–200 mA at 14 V, well inside 450 mA `(unverified: typical values)`. - Not from USB power: the coil must return into the board's GND terminal with the 7–36 V supply on VIN. - A ready-made 5 V relay module with an opto input also works: DO0 to its active-low `IN`, module VCC from `VOUT` set to 5 V (`H8` jumper, [[esp32-s3-touch-lcd-5b]]), grounds common. - The 2N2222 the user has is not needed on this board (no spare native GPIO). It would be the right part to drive a relay from an Inst. Cluster GPIO instead: GPIO → 1 kΩ → base, emitter to GND, coil between +12 V and the collector, same diode. ## Firmware `(repo, 2026-10-28)` `reverse_light.cpp`: every 100 ms, DO0 on ⇔ lever == R **and** CAN running **and** ignition on — the same snapshot the Driveline's big letter shows. A change is applied after two equal decisions (200 ms) so a one-frame glitch cannot chatter the relay. The CAN driver forgets the lever 2 s after the bus goes silent, and the key-off lever code `0xF0` clears ignition, so both turn the lamps off. The output is written through the panel library's expander object (OC0 = pin 8), never raw I2C: the backlight writes the library's cached OC register back to the chip on every on/off, so a raw write would be undone during an OTA install. Console: `reverse status | on | off | force on|off|auto`. `on/off` is saved (NVS `revlight_en`, default ON); `force` drives DO0 regardless of the lever for the wiring check, never saved, ends itself after 60 s. No Settings row — the System page is full at four rows. ## Check in the car 1. Bench first: `reverse force on` → relay clicks, lamps on; `reverse force off` → off. `reverse status` shows the DO0 state and write counters. 2. Car, key on, engine off: move the lever to R — lamps on within ~0.3 s, `[reverse] lights ON (lever R)` on the console; back to N/P — off. 3. Key off in R: lamps must go off (lever code `0xF0` clears ignition). 4. Watch for relay chatter when the lever passes through R between P and D; if any, raise `CONFIRM` in the module. Status: **not yet seen in the car** `(unverified)`. ## Related [[esp32-s3-touch-lcd-5b]] · [[esp32-s3-touch-lcd-5-schematic]] · [[diff-lock-inputs]] · [[can-id-candidates]] · [[nissan-patrol-swap]]