ESP32
Why the ESP32 is the microcontroller of choice for home cockpit builds — GPIO, PWM, Wi-Fi, and how to wire it up.
The ESP32 is a dual-core 240 MHz microcontroller with built-in Wi-Fi and Bluetooth. For a home cockpit it removes the need for a USB cable to every panel — each ESP32 connects wirelessly to the CockpitConnect backend and receives real-time dataref updates from X-Plane or MSFS over WebSockets.
| Feature | ESP32 | Arduino Uno | Arduino Mega |
|---|---|---|---|
| Clock speed | 240 MHz (dual core) | 16 MHz | 16 MHz |
| Flash memory | 4 MB | 32 KB | 256 KB |
| RAM | 520 KB | 2 KB | 8 KB |
| Wi-Fi | Built-in (802.11 b/g/n) | No | No |
| Bluetooth | Built-in (BLE + Classic) | No | No |
| PWM channels | 16 (LEDC) | 6 | 15 |
| ADC channels | 18 (12-bit) | 6 (10-bit) | 16 (10-bit) |
| Logic voltage | 3.3 V | 5 V | 5 V |
| Price (approx.) | €3–6 | €5–20 | €10–30 |
| Pin / Bus | GPIO(s) | Notes |
|---|---|---|
| I²C (SDA / SCL) | GPIO 21 / 22 | Default; reassignable in Wire.begin(sda, scl) |
| SPI (MOSI / MISO / SCK) | GPIO 23 / 19 / 18 | VSPI default; HSPI on 13/12/14 |
| UART 0 (USB serial) | GPIO 1 (TX) / 3 (RX) | Used by Serial monitor — avoid as general IO |
| UART 2 | GPIO 17 (TX) / 16 (RX) | Free for RS-232 / DMX / SBUS peripherals |
| Input-only | GPIO 34, 35, 36, 39 | No internal pull-up; no output; ADC capable |
| Strapping pins | GPIO 0, 2, 5, 12, 15 | Affect boot mode — safe to use after boot, but avoid pull-downs at startup |
A typical cockpit panel gets its own dedicated ESP32. Each board handles the inputs and outputs for one section — MCP, overhead, radio stack, gear lever — and communicates with the CockpitConnect backend over Wi-Fi. This means:
- No USB hubs, USB cable routing across the cockpit frame, or COM port management on the sim PC
- Panels can be physically removed or relocated without reconfiguring the simulator software
- Each panel is independently powered and can be swapped or updated over-the-air (OTA)
| Panel | Typical inputs | Typical outputs | I/O count |
|---|---|---|---|
| MCP / FCU | Rotary encoders, pushbuttons | 7-segment displays, backlight LEDs | 20–30 |
| Overhead panel | Toggle switches, pushbuttons | Annunciator LEDs | 30–60 (use I/O expanders) |
| Radio stack | Dual rotary encoders, flip-flop button | 7-segment or LCD displays | 10–20 |
| Gear / flap | Gear lever switch, flap lever | Gear position LEDs, warning horn | 5–10 |
| Instrument gauges | — | Servos / steppers for needle drives | 4–8 per gauge cluster |
The ESP32 has ~25 usable GPIOs on a standard DevKit. Overhead panels can require 50+ inputs. The MCP23017 I²C I/O expander adds 16 GPIO pins per chip; up to 8 chips can share one I²C bus (addresses 0x20–0x27), giving 128 additional pins on just two wires.
| Expander chip | Extra GPIOs | Interface | Max per bus |
|---|---|---|---|
| MCP23017 | 16 | I²C | 8 chips (128 pins) |
| MCP23S17 | 16 | SPI | 8 chips (128 pins) |
| PCF8574 | 8 | I²C | 8 chips (64 pins) |
| 74HC595 (shift register) | 8 outputs only | SPI / bit-bang | Chainable, unlimited |
// I²C bus scanner — finds all connected devices
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(21, 22); // SDA = GPIO 21, SCL = GPIO 22 (default)
Serial.println("Scanning I2C bus...");
for (uint8_t addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.print("Device found at 0x");
Serial.println(addr, HEX);
}
}
Serial.println("Done.");
}
void loop() {}The ESP32 connects to the home network and opens a WebSocket connection to the CockpitConnect backend. The backend proxies dataref values from X-Plane/MSFS in real time. Each panel subscribes to the datarefs it needs and reacts to changes — updating displays, moving servos, or lighting annunciators.
Each diagram shows the full circuit including the external power supply, shared GND bus, and the control signal from the ESP32. The key principle is the same in every case: the ESP32 provides only the signal; a separate supply provides the current.
Servo — external 5 V supply
ESP32 GPIO drives the signal wire only. VCC comes from a dedicated 5 V supply capable of delivering the stall current (500 mA for SG90, 2+ A for MG996R). Both the ESP32 VIN and the servo VCC are fed from the same 5 V rail; all GNDs join on a common bus.
LED — single vs. multi-LED panel
A single LED can be driven directly from a GPIO pin through a series resistor (purple dashed path using 3.3 V). For a bank of annunciator LEDs use a 5 V external supply with an NPN transistor (BC547) as a low-side switch — the GPIO drives the base through a 1 kΩ resistor, keeping GPIO current well under the 12 mA recommended limit.
Stepper motor — two separate supplies
The A4988 driver needs two distinct supplies: 12 V for the motor coils (VMOT) and 3.3 V for its logic (VDD). The ESP32 3V3 pin feeds VDD directly. Three GPIO pins carry STEP, DIR, and EN signals. A 100 µF electrolytic capacitor must be fitted across VMOT and GND close to the driver to suppress back-EMF spikes. All four GND connections — 12 V PSU, 5 V PSU, ESP32, and A4988 — tie together on the common bus.
The ESP32 itself draws ~240 mA peak (during Wi-Fi transmit bursts). The peripherals connected to a cockpit panel — servos, LED banks, stepper drivers — can draw several amperes. These loads must not be sourced from the ESP32's onboard 3.3 V regulator or the USB port. Use separate, appropriately rated supplies for each voltage rail, and connect all GNDs together at a single common point.
Powering the ESP32 board itself
| Method | Input voltage | When to use |
|---|---|---|
| USB (Micro-USB port) | 5 V | Development and bench testing only — USB supplies ~500 mA which is marginal under Wi-Fi load |
| VIN pin | 5–12 V | Finished panels — feed from a dedicated 5 V rail; passes through the onboard AMS1117 regulator (800 mA max) |
| 3V3 pin (direct) | 3.3 V regulated | When a lab PSU or external LDO already provides clean 3.3 V — bypasses the onboard regulator entirely |
Powering peripherals from external supplies
Each voltage rail that drives actuators or many LEDs should come from its own dedicated external power supply. The ESP32 only provides the control signals.
| Rail | Typical source | Peripherals | Recommended rating |
|---|---|---|---|
| 5 V | USB charger (5 V) or bench PSU | Servos (SG90, MG996R), 5 V LEDs, ULN2003 stepper boards | 3 A per panel minimum; 5–10 A for servo-heavy panels |
| 12 V | Desktop ATX PSU (12 V rail) or dedicated 12 V adapter | NEMA 17 stepper motors via A4988/DRV8825, solenoids, relays | 2–5 A depending on motor count; always fit 100 µF cap near driver |
| 3.3 V (logic only) | ESP32 3V3 pin or LDO regulator | I²C sensors, display logic, I/O expanders (MCP23017) | Keep total draw under 300 mA from ESP32's onboard regulator |
Common ground rule
Every supply in the system — ESP32 board, 5 V servo PSU, 12 V stepper PSU — must share a common GND. Without a shared ground the control signals from the ESP32 GPIOs have no return path and the peripherals will behave erratically or not at all.