π Deploy to Devices
The DEJA IO deploy wizard fetches your device configuration from Firebase, generates the right config files for the device type, and (optionally) flashes the firmware. The same wizard handles all four IO device types β deja-arduino, deja-esp32, deja-esp32-wifi, and deja-mqtt.
π¬ Running the Deploy Script
cd io
pnpm deploy
The interactive wizard walks you through:
- πΊοΈ Layout selection β pick the layout from your DEJA Cloud account
- π Device selection β pick a registered device (auto-filtered to flashable types)
- π WiFi/MQTT credentials β only for
deja-esp32-wifianddeja-mqtt: enter SSID, password, broker IP, optional username/password - π¦ Config generation β fetches device config, effects, turnouts, sensors, and signals from Firebase and writes platform-specific config files
- β¬οΈ Build & flash β compiles the firmware (or copies CircuitPython files) and uploads to the connected board
π οΈ
arduino-cliand theesp32:esp32core are auto-installed if not found on your system. Required Arduino libraries (Adafruit PWM Servo Driver Library,ArduinoJson,TurnoutPulser, and β fordeja-esp32-wifiβPubSubClient) are also auto-installed.
π¦ What Gets Deployed
π’ deja-arduino (Arduino Mega over USB)
Generates config.h with:
DEVICE_IDfrom your Cloud device entry- Feature flags based on what's configured (effects β
ENABLE_OUTPUTS, turnouts βENABLE_TURNOUTS, etc.) OUTPINS,SIGNALPINS,SENSORPINSarrays from your device's pin mappingTurnoutPulserdefinitions from your configured turnouts
Then compiles + uploads via arduino-cli against the Mega FQBN.
π deja-esp32 (ESP32 over USB)
Same config.h shape as deja-arduino (the sketch is shared) β only the build target changes. Compiles + uploads via arduino-cli against the ESP32 FQBN at 460800 baud upload speed.
π deja-esp32-wifi (ESP32 over WiFi/MQTT)
Generates config.h with everything deja-arduino ships plus the WiFi/MQTT credentials baked in at build time:
WIFI_SSID,WIFI_PASSWORDβ entered during the wizardMQTT_BROKER,MQTT_PORT,MQTT_USERNAME,MQTT_PASSWORDβ entered during the wizardLAYOUT_ID,DEVICE_ID,TOPIC_IDβ sourced from your Cloud config
Then compiles + uploads against the ESP32 FQBN. After flashing, the device connects to WiFi, subscribes to {TOPIC_ID}/{LAYOUT_ID}/{DEVICE_ID}, and starts processing commands.
π deja-mqtt (Raspberry Pi Pico W)
Generates:
settings.tomlwith WiFi credentials, MQTT broker address, layout ID, and device IDconfig.jsonwith the pin mapping from your device configuration
Then copies code.py, lib/, settings.toml, and config.json to the mounted CIRCUITPY drive β no compilation required.
π οΈ Manual Build & Flash (Arduino-family only)
If you'd rather flash by hand, every Arduino-family build drops out a self-contained bundle at io/dist/<layoutId>/arduino/<deviceId>/ that works with PlatformIO, Arduino CLI, or the Arduino IDE. The exact CLI commands depend on the device type β these come straight from getCliDeployCommands() in packages/modules/device-config/cli-commands.ts (the single source of truth shown in each bundle's DEPLOYMENT.md and on the Cloud app device details page):
π’ deja-arduino
# 1οΈβ£ Build the bundle
pnpm --filter=@deja/io build:firmware -- --layout <layoutId> --device <deviceId>
# 2οΈβ£ cd into the bundle
cd io/dist/<layoutId>/arduino/<deviceId>
# 3aοΈβ£ PlatformIO
platformio run -e megaatmega2560 --target upload --upload-port /dev/cu.usbserial-*
# 3bοΈβ£ Arduino CLI
arduino-cli compile --fqbn arduino:avr:mega:cpu=atmega2560 deja-arduino && \
arduino-cli upload -p /dev/cu.usbserial-* --fqbn arduino:avr:mega:cpu=atmega2560 deja-arduino
π deja-esp32
pnpm --filter=@deja/io build:firmware -- --layout <layoutId> --device <deviceId>
cd io/dist/<layoutId>/arduino/<deviceId>
# PlatformIO
platformio run -e esp32dev --target upload --upload-port /dev/cu.usbserial-*
# Arduino CLI
arduino-cli compile --fqbn esp32:esp32:esp32 \
--build-property "compiler.cpp.extra_flags=-std=c++17" deja-arduino && \
arduino-cli upload -p /dev/cu.usbserial-* \
--fqbn esp32:esp32:esp32:UploadSpeed=460800 deja-arduino
π deja-esp32-wifi
pnpm --filter=@deja/io build:firmware -- --layout <layoutId> --device <deviceId>
cd io/dist/<layoutId>/arduino/<deviceId>
# PlatformIO
platformio run -e esp32dev --target upload --upload-port /dev/cu.usbserial-*
# Arduino CLI
arduino-cli compile --fqbn esp32:esp32:esp32 \
--build-property "compiler.cpp.extra_flags=-std=c++17" deja-esp32-wifi && \
arduino-cli upload -p /dev/cu.usbserial-* \
--fqbn esp32:esp32:esp32:UploadSpeed=460800 deja-esp32-wifi
π If you ran
pnpm build:firmwarenon-interactively, the WiFi/MQTT credentials indeja-esp32-wifi/config.hwill be empty β edit them by hand before flashing or re-run the interactive wizard.
deja-mqtt doesn't have a CLI build path because Pico W firmware is just CircuitPython files copied to the CIRCUITPY drive.
π₯ Firebase Configuration Source
The deploy script reads from Firestore:
| Collection | Data |
|---|---|
layouts/{layoutId}/devices/{deviceId} | Device type, connection, pin mapping |
layouts/{layoutId}/effects | Effects assigned to this device |
layouts/{layoutId}/turnouts | Turnouts assigned to this device |
layouts/{layoutId}/sensors | Sensors assigned to this device |
layouts/{layoutId}/signals | Signals assigned to this device |
Your device must be registered in the Cloud app before deploying. See Cloud β Devices.
ποΈ Layout-Specific Configs
For Pico W layouts with customized wiring, place override configs at:
io/layouts/{layoutId}/deja-pico-w/{deviceId}/config.json
The deploy script checks for layout-specific configs first, falling back to the device's Cloud configuration.
π Next Steps
- π§ Arduino & ESP32 Setup β hardware setup and
config.hreference - π Pico W Setup β CircuitPython setup and
settings.tomlreference - βοΈ Configuration Reference β all generated file formats per device type