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)
🟢 deja-arduinoconfig.h (compile-time)
🟠 deja-esp32config.h (compile-time)
🛜 deja-esp32-wificonfig.h (compile-time, with baked WiFi/MQTT)
🍓 deja-mqtt (Pico W)settings.toml + config.json (runtime)

deja deploy generates all of these automatically from your device's configuration in the Cloud app — you shouldn't normally need to hand-edit them. This reference is here for when you want to understand (or manually tweak) what got generated.


🟢🟠 Arduino & ESP32 USB — config.h

Compile-time configuration shared by deja-arduino and deja-esp32. The Arduino firmware reads these values at build time.

🚦 Feature Flags

deja deploy computes each flag from what's actually configured on the device in the Cloud app (for example, ENABLE_OUTPUTS is true only if an effect has a pin assigned) — see Deploy to Devices. If no generated config.h exists yet, the firmware falls back to config.default.h, which ships with every flag below set to false.

FlagTypeDescription
DEVICE_IDstringUnique device identifier — must match your Cloud device entry
ENABLE_PWMbool🎛️ Enable PCA9685 servo driver support
ENABLE_OUTPUTSbool💡 Enable digital GPIO outputs
ENABLE_SIGNALSbool🚦 Enable signal head control
ENABLE_SENSORSbool📡 Enable sensor input reading
ENABLE_TURNOUTSbool🔧 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)

🎛️ PCA9685 Wiring & Timing

Present when ENABLE_PWM is on, generated from your device's PCA9685 wiring in the Cloud app:

#define PCA9685_SDA_PIN 21
#define PCA9685_SCL_PIN 22
#define PWM_OSCILLATOR_FREQ 27000000L
  • PCA9685_SDA_PIN / PCA9685_SCL_PIN — I2C pins the PCA9685 board is wired to
  • PWM_OSCILLATOR_FREQ — the PCA9685's internal oscillator frequency, used to calibrate servo pulse timing

🛜 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_SSIDstringWiFi network name
WIFI_PASSWORDstringWiFi password

📬 MQTT Settings

DefineTypeRequiredDescription
MQTT_BROKERstringMQTT broker IP / hostname
MQTT_PORTintMQTT broker port (default 1883)
MQTT_USERNAMEstringoptionalMQTT username (leave empty for anonymous)
MQTT_PASSWORDstringoptionalMQTT password

🏷️ Device Identity

DefineTypeRequiredDescription
DEVICE_IDstringUnique device identifier (matches the Firestore device doc)
LAYOUT_IDstringLayout identifier
TOPIC_IDstringMQTT 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").