flatpanel/WIRING.md
Laurence c32f00a2be Initial release v1.1.0 — ESP32 automated telescope flat panel
Firmware (Arduino Nano ESP32 / PlatformIO):
- Native ASCOM Alpaca CoverCalibrator REST API on port 11111
- Alnitak serial protocol on USB at 9600 baud (simultaneous with WiFi)
- MG995 servo cover mechanism with non-blocking state machine (D9)
- LED brightness PWM via IRLZ44N MOSFET, LEDC channel 0 (D3)
- 12V dew heater PWM via IRLZ44N MOSFET, LEDC channel 1 (D5)
- mDNS + UDP Alpaca discovery, WiFi watchdog reconnect
- SERIAL_DEBUG flag to silence debug output in USB-only mode

INDI driver (C++ / libcurl / nlohmann-json):
- WiFi mode: HTTP Alpaca via libcurl
- USB mode: Alnitak serial via POSIX termios
- LightBoxInterface + DustCapInterface + dew heater number property

Python controller (PyQt6):
- Dark-themed desktop app for direct manual control
- AlpacaBackend (requests) + AlnitakBackend (pyserial)
- PollWorker QThread; cover, brightness, dew heater panels
- QSettings persistence; auto serial port discovery

Docs:
- system-diagram.svg, wiring-diagram.svg (browser-renderable SVG)
- BUILD_NOTES.md with BOM, LM2596 calibration, power-on checklist
- WIRING.md quick-reference, README.md, CHANGELOG.md
2026-05-17 08:51:29 +01:00

8.4 KiB
Raw Permalink Blame History

ESP32 FlatPanel Wiring & BOM

What to buy

Item Purpose Notes
IRLZ44N N-channel MOSFET × 2 LED brightness + dew heater control Logic-level: 3.3 V gate from ESP32 is sufficient. One per load.
100 Ω resistor × 2 (1/4 W) MOSFET gate current limiting One per MOSFET
10 kΩ resistor × 2 (1/4 W) MOSFET gate pull-down Ensures loads are off at boot
White LED strip or panel (12 V) Flat-field illumination surface High-CRI (Ra > 90) recommended. Size to scope aperture.
Frosted acrylic sheet Light diffuser 3 mm thick, cut to scope outer diameter
Dew heater element (12 V, ~5-10 W) Prevents flat panel misting up Nichrome wire mat, resistive heating tape, or commercial dew strap cut to fit. ~24 Ω for 6 W at 12 V.
LM2596 or MP1584 buck converter module 12 V → 5 V for servo Set output to 5.0 V before connecting
12 V DC power supply (≥ 4 A) Powers everything LED 2 A + dew heater 0.5 A + servo 1 A peak
1N4007 diode Optional: reverse-polarity protection on 12 V input
Prototype / strip board Assembly
JST connectors or screw terminals Clean connections
Aluminium or 3D-printed enclosure Mechanical housing

Component roles

Component Role
Arduino Nano ESP32 Main controller: WiFi, Alpaca server, PWM, servo
MG995 servo Rotates the flat panel lid in / out of the telescope light path
SG90 micro servo Spare / future use (e.g., secondary aperture cover)
28BYJ-48 stepper Spare / future use (e.g., precision ND-filter wheel for extra dimming)
IRLZ44N MOSFET Controls LED strip power via PWM from ESP32

Wiring diagram

12 V PSU ──────────────────────────────────────────── 12 V rail
          │                                               │
          │   LM2596 buck (set to 5 V)                   │
          ├──[IN+]──[OUT+]──────────────── 5 V rail       │
          │   [IN-]──[OUT-]─────────────── GND rail       │
          │                                               │
          └── GND ──────────────────────── GND rail       │
                                                          │
  ┌─────────── Arduino Nano ESP32 ───────────────────┐   │
  │  VIN ◄──── 5 V rail                              │   │
  │  GND ◄──── GND rail                              │   │
  │                                                  │   │
  │  D9  ──────────────────────────► MG995 Signal    │   │
  │  5 V rail ─────────────────────► MG995 VCC (5V)  │   │
  │  GND ──────────────────────────► MG995 GND       │   │
  │                                                  │   │
  │  D3 ──[100 Ω]──► MOSFET-A Gate (LED)            │   │
  │  GND ──[10 kΩ]──► MOSFET-A Gate (pull-down)     │   │
  │                    MOSFET-A Source ──► GND rail  │   │
  │                    MOSFET-A Drain  ──► LED-      │   │
  │                                                  │   │
  │  D5 ──[100 Ω]──► MOSFET-B Gate (dew heater)    │   │
  │  GND ──[10 kΩ]──► MOSFET-B Gate (pull-down)     │   │
  │                    MOSFET-B Source ──► GND rail  │   │
  │                    MOSFET-B Drain  ──► Heater-   │   │
  └──────────────────────────────────────────────────┘   │
                                                          │
  LED strip/panel:  LED+ ◄────────────────── 12 V rail ──┤
                    LED- ◄────────────────── MOSFET-A Drain
                                                          │
  Dew heater:   Heater+ ◄────────────────── 12 V rail ───┘
                Heater- ◄────────────────── MOSFET-B Drain

MOSFET pinout (IRLZ44N TO-220, flat face towards you)

  Gate | Drain | Source
   1       2       3

Connect:

  • Gate (1) → 100 Ω → D3, with 10 kΩ from Gate to GND
  • Drain (2) → LED strip negative lead
  • Source (3) → GND rail

Servo signal cable colours (standard)

Colour Signal
Brown / Black GND
Red VCC (5 V)
Orange / Yellow / White Signal (PWM)

Pin summary

ESP32 pin Function Config define
D9 MG995 servo signal SERVO_PIN
D3 LED PWM (MOSFET-A gate) LED_PWM_PIN
D5 Dew heater PWM (MOSFET-B gate) DEW_HEATER_PIN

Dew heater element sizing

12 V supply Resistance Power Suitable for panel size
48 Ω 3 W Up to 3″ aperture
24 Ω 6 W 4-6″ aperture (recommended)
12 Ω 12 W 8″+ aperture

Use nichrome wire, resistive heating tape, or a commercial dew strap wound flat under the acrylic diffuser. The MOSFET PWM keeps average power proportional to the 0-100 % setting — you do not need to match exact resistance; just aim for 5-10 W at 12 V.


Choosing between WiFi and USB mode

WiFi (Alpaca) USB Serial (Alnitak)
Cable required No Yes (USB-A to USB-C)
Works with ASCOM Remote, our INDI driver N.I.N.A. built-in, SGPro, APT, indi_flipflat, our INDI driver
Dew heater control Via Alpaca Action (our driver) Via custom T/U serial commands (our driver only)
Debug output Set SERIAL_DEBUG true Set SERIAL_DEBUG false
Discovery mDNS + UDP broadcast COM port / /dev/ttyUSBx

For USB mode, edit config.h and set SERIAL_DEBUG false before flashing, then open the COM port at 9600 baud in your software.


First-time setup checklist

  1. Set LM2596 output to 5.0 V (measure with multimeter) before connecting servo.
  2. Edit firmware/src/config.h — set WIFI_SSID, WIFI_PASSWORD.
    • For USB-only use: also set SERIAL_DEBUG false.
  3. Adjust SERVO_OPEN / SERVO_CLOSED angles for your mechanical setup.
  4. Flash firmware via PlatformIO: pio run -t upload.
  5. WiFi mode: open Serial Monitor (9600 baud) — note the printed IP address, then browse to http://<IP>:11111/management/v1/configureddevices.
  6. USB mode: connect to the COM port at 9600 baud and send >P000 — you should receive *P19000.

ASCOM setup (Windows)

  1. Install ASCOM Platform 6.6+.
  2. Install ASCOM Remote (acts as Alpaca → COM bridge).
  3. In ASCOM Remote, add a CoverCalibrator device pointing to http://esp32-flatpanel.local:11111.
  4. In your imaging software (N.I.N.A., SGPro, APT) select the "ASCOM Remote CoverCalibrator" driver.

INDI setup (Linux / Raspberry Pi)

# Build dependencies
sudo apt install libindi-dev libcurl4-openssl-dev nlohmann-json3-dev cmake

# Build
cd flatpanel/indi-driver
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr
cmake --build build -j$(nproc)
sudo cmake --install build

# Run (KStars/Ekos will load it automatically once installed)
# Or manually:
indiserver indi_esp32_flatpanel

In KStars → Ekos, select ESP32 FlatPanel in the Aux device drop-down.

  • WiFi mode: select "WiFi / Alpaca" in the Connection Mode switch, enter the host (esp32-flatpanel.local) and port (11111), then connect.
  • USB mode: select "USB Serial (Alnitak)", enter the serial port (/dev/ttyUSB0 or /dev/ttyACM0), then connect. The dew heater slider is available in both modes.

Alternative for USB mode (no custom driver needed): The existing indi_flipflat driver (ships with INDI) speaks standard Alnitak and will control brightness and cover. It will not control the dew heater — use our driver for that.

indiserver indi_flipflat
# Select port /dev/ttyUSB0, baud 9600