Skip to main content

Electronics & Microcontrollers

Full electronics documentation for the 737 MAX build — ESP32 wiring, encoders, displays, LED backlighting, and CockpitConnect integration with X-Plane 12.

12 min read Updated 2026-11

Architecture Overview

Every input in this cockpit runs through ESP32 controllers, CockpitConnect and X-Plane 12:

Physical Input
  → ESP32 (CockpitConnect firmware)
    → WiFi
      → CockpitConnect Bridge (SimPC) — runs the Flows
        → X-Plane 12 command or dataref

Outputs (annunciators, displays, backlighting) flow the other way: X-Plane 12 changes a dataref, the Flow turns it into a hardware command, and the ESP32 lights the LED or updates the display. The simulator is always the source of truth: pressing a button only changes a light after X-Plane 12 confirms it.

No sketches are written for this build. Every board runs the same CockpitConnect firmware, and what each pin does is set in the Flow Builder.


Board Selection

Each panel zone gets its own ESP32, so wiring runs stay short and one board never holds up another.

ZoneBoardWhy
MCPESP32-S3-DevKitC-1Six encoders plus a display chain need the extra GPIOs
Overhead (fwd)ESP32 DevKit V1Switches sit on I²C expanders, so few GPIOs are needed
Overhead (aft)ESP32 DevKit V1Same as forward
PedestalESP32 DevKit V1Levers, reed switches and analog inputs

See Supported boards for every board CockpitConnect runs on. All boards are flashed once from the browser and then updated over the air.


MCP Wiring

Rotary Encoders

Encoders (Bourns PEC11R) use two GPIOs each plus a common ground. On the MCP's ESP32-S3:

EncoderGPIOsFlow binding (X-Plane 12)
SPD4, 5sim/autopilot/airspeed_up / _down
HDG6, 7sim/autopilot/heading_up / _down
ALT15, 16sim/autopilot/altitude_up / _down
VS17, 18sim/autopilot/vertical_speed_up / _down
CRS 138, 39Course selector, captain side
CRS 240, 41Course selector, first officer side

Debouncing: set debounceMs per pin in the GPIO config; the controller filters before the Flow sees an event. For electrically noisy wiring, also add a 100 nF capacitor between each encoder pin and GND.

Buttons and Switches

The MCP's 14 pushbuttons and 8 toggle switches sit on MCP23017 I²C expanders (SDA GPIO 8, SCL GPIO 9), so they cost two GPIOs in total. Each button is a Component on an expander channel and is bound in a Flow, for example the AP button to sim/autopilot/servos_toggle.

7-Segment Displays

The SPD, HDG, ALT and VS readouts are 0.56" common-cathode digits driven by three MAX7219 chips in one chain (DIN GPIO 11, CLK GPIO 12, CS GPIO 13). Each readout is a Digit Window on the chain, bound to its dataref:

ReadoutDataref
SPDsim/cockpit2/autopilot/airspeed_dial_kts_mach
HDGsim/cockpit2/autopilot/heading_dial_deg_mag_pilot
ALTsim/cockpit2/autopilot/altitude_dial_ft
VSsim/cockpit2/autopilot/vvi_dial_fpm

3.3 V logic: the MAX7219 runs at 5 V and is not 3.3 V compatible, so DIN and CLK go through a level shifter. See 7-segment displays.


Backlighting System

LED Architecture

The backlight system uses two types of LEDs:

  1. WS2812B addressable LEDs — panel flood lighting and RGB annunciators, as an LED Strip on GPIO 14
  2. Individual 3mm warm-white LEDs — through-legend backlighting on the acrylic overlay

The strip's brightness follows the panel-lights knob in X-Plane 12 through a Flow, so dimming the virtual cockpit dims the real one. All strips are on a shared 5V / 3A supply, and the 3.3 V data line goes through a 74AHCT125 level shifter.

Tip: Real 737 MAX panel lighting is a warm amber-white at around 2700K. RGB (255, 200, 120) is a close approximation with WS2812B LEDs.

Annunciator LEDs

Annunciators are individual 3mm LEDs on expander outputs, each through a 330Ω resistor:

Expander output → 330Ω Resistor → LED Anode → LED Cathode → GND

Each LED is bound in a Flow to its status dataref, for example the AP light to sim/cockpit2/autopilot/servos_on.


Overhead Panel — I²C Expanders

The overhead panel has over 200 switches, so each overhead board puts its switches on MCP23017 I²C expanders on a shared 2-wire bus:

ESP32 SDA (GPIO 21) ─────┬──────────────────────
ESP32 SCL (GPIO 22) ─────┼─┬────────────────────
                         │ │
                   MCP23017 #1 (addr 0x20) → 16 switches
                   MCP23017 #2 (addr 0x21) → 16 switches
                   MCP23017 #3 (addr 0x22) → 16 switches
                   ... up to 8 expanders per bus

Each expander has 3 address pins (A0, A1, A2), giving 8 unique addresses (0x20–0x27). Add the expander to the board in the Flow Builder, then add each switch as a Component on one of its channels. No code is needed. See I/O expanders for wiring and pull-ups.


Power Supply

RailVoltageCurrentPowers
PSU 5V5V DC5AESP32s (5V pin), WS2812B strips
PSU 12V12V DC2AFuture: stepper motors (trim wheel)

All ESP32s share a common 5V / GND bus from a single ATX power supply (silent fan, repurposed from a PC). No board has a USB cable to the PC: they talk to the Bridge over WiFi.

Critical: Always connect all GNDs together — ESP32 GND, LED strip GND, and PSU GND must share a common reference or the WS2812B LEDs will flicker or behave erratically.


Troubleshooting

Encoder skips steps or double-triggers → Add 100nF caps between encoder pins and GND. Increase the pin's debounceMs in the GPIO config.

WS2812B LEDs flash white on startup → Add a 300–500Ω resistor on the data line and a 1000µF cap across VCC/GND near the strip.

A board doesn't show up → Check that it is on the same network as the Bridge. Boards are found automatically over mDNS; the status LED shows whether WiFi or the Bridge connection is missing.

A button does nothing in the sim → Use the Input Scan in the app to check the press reaches CockpitConnect, then check the Flow's command for the aircraft you are flying (some third-party aircraft use their own commands and datarefs).