⚙️ Configuration Reference
DEJA IO devices use different configuration formats depending on the device type and transport. This reference covers all of them.
| Device type | Config file(s) |
|---|---|
🟢 deja-arduino |
config.h (compile-time) |
🟠 deja-esp32 |
config.h (compile-time) |
🛜 deja-esp32-wifi |
config.h (compile-time, with baked WiFi and MQTT or WebSocket settings) |
🍓 deja-mqtt (Pico W) |
settings.toml + config.json (runtime) |
deja deploy generates all of these automatically from your device's configuration in Throttle — 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 Throttle (for example, ENABLE_OUTPUTS is true only if an effect has a pin assigned) — see Deploy to Devices. A generated config.h starts with #define DEJA_BAKED 1, which tells the firmware to use the values on this page.
If there is no config.h, the sketch builds from config.default.h instead. That is the generic image the browser installer flashes: it has no pins of its own and drives nothing until the installer writes the device's config into it.
🧓 Arduino IDE users with an older config.h: a hand-kept config.h from before DEJA_BAKED existed still works. Because it defines DEVICE_ID, the firmware treats it as baked and builds exactly as before. Regenerating it is optional.
| Flag | Type | Description |
|---|---|---|
DEJA_BAKED |
1 |
🧱 Marks the header as a complete device config (written by deja deploy and the Manual pane) |
DEVICE_ID |
string | Unique device identifier — must match the device ID registered in Throttle |
ENABLE_PWM |
bool | 🎛️ Enable PCA9685 servo driver support |
ENABLE_OUTPUTS |
bool | 💡 Enable digital GPIO outputs |
ENABLE_SIGNALS |
bool | 🚦 Enable signal head control |
ENABLE_SENSORS |
bool | 📡 Enable sensor input reading |
ENABLE_TURNOUTS |
bool | 🔧 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)
int SENSORMODES[] = {}; // INPUT or INPUT_PULLUP, parallel to SENSORPINS
🔧 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 Throttle:
#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 toPWM_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 transport settings in at build time. The deja deploy wizard prompts for WiFi plus the MQTT broker or, for WebSocket devices, the DEJA server host and port, and writes them in via generateEsp32WifiConfig().
📶 WiFi Settings
| Define | Type | Required | Description |
|---|---|---|---|
WIFI_SSID |
string | ✅ | WiFi network name |
WIFI_PASSWORD |
string | ✅ | WiFi password |
🔌 Transport
| Define | Type | Required | Description |
|---|---|---|---|
DEJA_TRANSPORT_WS |
int | ✅ | 0 = MQTT, 1 = WebSocket to the DEJA server. Set from the device's Transport |
📬 MQTT Settings (DEJA_TRANSPORT_WS 0)
| Define | Type | Required | Description |
|---|---|---|---|
MQTT_BROKER |
string | ✅ | MQTT broker IP / hostname |
MQTT_PORT |
int | ✅ | MQTT broker port (default 1883) |
MQTT_USERNAME |
string | optional | MQTT username (leave empty for anonymous; the wizard doesn't ask — edit by hand) |
MQTT_PASSWORD |
string | optional | MQTT password (edit by hand) |
🔌 WebSocket Settings (DEJA_TRANSPORT_WS 1)
| Define | Type | Required | Description |
|---|---|---|---|
WS_HOST |
string | ✅ | DEJA server LAN IP / hostname (the wizard defaults to this machine's LAN IPv4) |
WS_PORT |
int | ✅ | DEJA server WebSocket port (default 8082) |
WS_TOKEN |
string | ✅ | Per-device token (64 hex characters) generated by deja deploy; only its hash is stored in DEJA Cloud |
🏷️ Device Identity
| Define | Type | Required | Description |
|---|---|---|---|
DEVICE_ID |
string | ✅ | Unique device identifier (matches the Firestore device doc) |
LAYOUT_ID |
string | ✅ | Layout identifier |
TOPIC_ID |
string | ✅ | MQTT topic prefix ("DEJA" — the server always uses it) |
🚦 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.
SENSOR_DEBOUNCE_MS (default 500) sets the minimum time between sensor state changes.
🛜 If you change WiFi, MQTT or WebSocket settings, 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.
| Variable | Required | Description |
|---|---|---|
CIRCUITPY_WIFI_SSID |
✅ | 📶 WiFi network name |
CIRCUITPY_WIFI_PASSWORD |
✅ | 🔑 WiFi password |
TRANSPORT |
No | 🔌 "mqtt" (default) or "websocket" |
MQTT_BROKER |
MQTT only | 🌐 MQTT broker IP address |
MQTT_PORT |
No | 📡 MQTT broker port (default "1883") |
WS_HOST |
WebSocket only | 🖥️ DEJA server LAN IP / hostname |
WS_PORT |
No | 🔌 DEJA server WebSocket port (default "8082") |
WS_TOKEN |
WebSocket only | 🔐 Per-device token generated by deja deploy |
LAYOUT_ID |
✅ | 🗺️ Your layout ID in DEJA Cloud |
DEVICE_ID |
✅ | 🏷️ Unique device identifier |
TOPIC_ID |
No | 📡 MQTT topic prefix ("DEJA") |
ENABLE_CONFIG |
No | ⚙️ Load pins, turnouts and sensors from config.json (default: "true") |
ENABLE_PWM |
No | 🎛️ Enable PCA9685 servo support — only when "true". The generator uses the device's enablePwm setting when it is set, otherwise turns PWM on when servo turnouts are assigned |
🍓 Pico W — config.json
Pin mapping from logical pin numbers to physical CircuitPython GPIO names, plus the device's Kato turnouts and sensors.
{
"pins": {
"6": "GP6",
"7": "GP7",
"8": "GP8",
"9": "GP9"
},
"turnouts": [
{ "index": 0, "straight": "GP14", "divergent": "GP15", "pulseMs": 250 }
],
"sensors": [
{ "index": 0, "pin": "GP20", "debounceMs": 100 }
]
}
pins— keys are the logical pin numbers used in commands ("pin": 8); values are CircuitPython GPIO names ("GP8").turnouts— Kato turnouts, addressed by position inturnoutcommands.state: falsepulsesstraight,truepulsesdivergent, forpulseMs.sensors— inputs reported as{ "device", "sensor": index, "state" }on each change;debounceMs(default 100) is the minimum time between two reported changes of the same sensor, not a hold time.