Skip to main content

βš™οΈ Configuration Reference

DEJA IO devices use different configuration formats depending on the device type and transport. This reference covers all of them.

Device typeConfig file(s)Generator
🟒 deja-arduinoconfig.h (compile-time)generateArduinoConfig()
🟠 deja-esp32config.h (compile-time)generateArduinoConfig()
πŸ›œ deja-esp32-wificonfig.h (compile-time, with baked WiFi/MQTT)generateEsp32WifiConfig()
πŸ“ deja-mqtt (Pico W)settings.toml + config.json (runtime)generatePicoSettings() + generatePicoConfig()

All generators live in @repo/modules/device-config and are shared between the Cloud app, the IO build/deploy scripts, and the deja deploy CLI.


🟒🟠 Arduino & ESP32 USB β€” config.h

Compile-time configuration shared by deja-arduino and deja-esp32. The Arduino firmware reads these values at build time. Located at io/src/deja-arduino/config.h (copy from config.default.h if it doesn't exist).

🚦 Feature Flags

FlagTypeDefaultDescription
DEVICE_IDstring"deja-arduino"Unique device identifier β€” must match your Cloud device entry
ENABLE_PWMbooltrueπŸŽ›οΈ Enable PCA9685 servo driver support
ENABLE_OUTPUTSbooltrueπŸ’‘ Enable digital GPIO outputs
ENABLE_SIGNALSbooltrue🚦 Enable signal head control
ENABLE_SENSORSbooltrueπŸ“‘ Enable sensor input reading
ENABLE_TURNOUTSbooltrueπŸ”§ Enable servo-driven turnouts

πŸͺ› Pin Arrays

int OUTPINS[] = {8, 9, 10, 11};       // Digital output GPIO pins
int SIGNALPINS[] = {4, 5, 6, 7};      // Signal head GPIO pins
int SENSORPINS[] = {A0, A1, A2};      // Sensor input pins (analog or digital)

πŸ”§ Turnout Definitions

TurnoutPulser turnouts[] = {
  TurnoutPulser(channel, closedAngle, thrownAngle),
};
  • channel β€” PCA9685 servo channel (0–15)
  • closedAngle β€” servo angle for closed position (degrees)
  • thrownAngle β€” servo angle for thrown position (degrees)

πŸ›œ ESP32 WiFi β€” config.h

Compile-time configuration for deja-esp32-wifi. The sketch lives at io/src/deja-esp32-wifi/. Unlike the Pico W (which reads settings.toml at runtime), the ESP32 WiFi firmware bakes WiFi and MQTT credentials in at build time. The deja deploy wizard prompts for these and writes them in via generateEsp32WifiConfig().

πŸ“Ά WiFi Settings

DefineTypeRequiredDescription
WIFI_SSIDstringβœ…WiFi network name
WIFI_PASSWORDstringβœ…WiFi password

πŸ“¬ MQTT Settings

DefineTypeRequiredDescription
MQTT_BROKERstringβœ…MQTT broker IP / hostname
MQTT_PORTintβœ…MQTT broker port (default 1883)
MQTT_USERNAMEstringoptionalMQTT username (leave empty for anonymous)
MQTT_PASSWORDstringoptionalMQTT password

🏷️ Device Identity

DefineTypeRequiredDescription
DEVICE_IDstringβœ…Unique device identifier (matches the Firestore device doc)
LAYOUT_IDstringβœ…Layout identifier
TOPIC_IDstringβœ…MQTT topic prefix (default "DEJA")

🚦 Feature Flags & Pin Arrays

ENABLE_PWM / ENABLE_OUTPUTS / ENABLE_SIGNALS / ENABLE_SENSORS / ENABLE_TURNOUTS and the OUTPINS / SIGNALPINS / SENSORPINS / TurnoutPulser definitions all use the same semantics as the deja-arduino config above.

πŸ›œ If you change WiFi or MQTT credentials, you have to re-flash the device β€” the values are compiled in.


πŸ“ Pico W β€” settings.toml

Runtime environment configuration for deja-mqtt. Loaded by CircuitPython at boot.

VariableRequiredDescription
CIRCUITPY_WIFI_SSIDβœ…πŸ“Ά WiFi network name
CIRCUITPY_WIFI_PASSWORDβœ…πŸ”‘ WiFi password
MQTT_BROKERβœ…πŸŒ MQTT broker IP address
LAYOUT_IDβœ…πŸ—ΊοΈ Your layout ID in DEJA Cloud
DEVICE_IDβœ…πŸ·οΈ Unique device identifier
TOPIC_IDNoπŸ“‘ MQTT topic prefix (default: "DEJA")
ENABLE_CONFIGNoβš™οΈ Load pin mapping from config.json (default: "true")
ENABLE_PWMNoπŸŽ›οΈ Enable PCA9685 servo support (default: "true")
ENABLE_MQTTNoπŸ“¬ Enable MQTT communication (default: "true")

πŸ“ Pico W β€” config.json

Pin mapping from logical pin numbers to physical CircuitPython GPIO names.

{
  "pins": {
    "6": "GP6",
    "7": "GP7",
    "8": "GP8",
    "9": "GP9"
  }
}

Keys are the logical pin numbers used in commands ("pin": 8). Values are CircuitPython GPIO names ("GP8").


πŸ—‚οΈ Layout-Specific Overrides

Per-layout configs live under:

io/layouts/{layoutId}/deja-pico-w/{deviceId}/config.json

When the deploy script runs, it uses the layout-specific config instead of the default io/src/deja-pico-w/config.json.