Documentation
Set up Loco Panel
Everything you need to get from a download to throwing turnouts: installing the app and the LocoNet gateway, connecting them, importing your layout and mapping it to your hardware.
This guide is for Loco Panel 2.1.2 and gateway 2.1.0, the latest releases.
How it fits together
Loco Panel never talks to LocoNet directly. It sends and receives short text messages over MQTT, and a small gateway on a Raspberry Pi translates those to and from LocoNet through a Digitrax interface.
Loco Panel → MQTT broker (Mosquitto) → LocoNet gateway (Raspberry Pi) → Digitrax DCS52 / PR4 → LocoNetYou need:
- A Digitrax DCS52 or PR4 connected to the Pi by USB.
- A Raspberry Pi (or another Debian-style Linux machine with
aptand systemd) on the same network as the computer or tablet running Loco Panel. - An MQTT broker. The gateway installer sets up Mosquitto on the Pi for you.
- Your layout as a JMRI Layout Editor or AnyRail XML export. Loco Panel includes a starter layout so you can look around first.
Quick start
- Download Loco Panel for your device.Desktop macOS Windows Linuxx64Mobile & Web Android Web app
Latest: app 2.1.2, gateway 2.1.0 · release notes · app · gateway releases
- Install the gateway. On the Pi, run the one-line installer and choose your Digitrax serial device when asked.
curl -fsSL https://github.com/LocoPanel/loconet-gateway-releases/releases/latest/download/get.sh | sudo bash - Connect the app to MQTT. Open settings (gear icon) and enter the Pi's address. The status dot turns green when the app and gateway are both up.
- Name things by address. In JMRI or AnyRail, start every turnout and block name with its LocoNet number, such as
5 Yard Leador6 Outer North. That number is the address Loco Panel sends and listens for, so it has to match your hardware, and each number must be unique. Naming rules - Import your layout. Use the upload icon to load your JMRI or AnyRail XML.
- Check the IDs. Open the table icon and confirm each turnout and block ID matches its LocoNet address.
- Run trains. Tap a turnout, or use the CTC panel's levers and Code Start button.
Install Loco Panel
Get the build for your device from the Quick start. Notes for each platform:
- macOS: open the
.dmgand drag Loco Panel to Applications. - Windows: run the setup installer.
- Linux: the button defaults to the x64 AppImage; use its arrow to pick arm64 (for example a Raspberry Pi). Make the file executable (
chmod +x LocoPanel-linux-*.AppImage) and run it. - Android: open the downloaded
.apk. Android will ask you to allow installs from your browser or file manager the first time. - Web: nothing to install; see Web app.
iPad: the iPad app is in beta through TestFlight. Email me the address for your Apple ID and I'll add you as a tester; you'll get an invitation from TestFlight to install it.
On first launch you'll see a starter layout. Once you import your own it's remembered and the starter is no longer used. Your broker settings and view choices are remembered too, and the broker password is kept in the system keychain rather than in a plain settings file.
Install the gateway
The gateway is a small Python service that runs on the Raspberry Pi as a systemd service. Plug in your DCS52 or PR4, power it, then run the one-line installer from the Quick start.
When run from a terminal, the installer lists the serial devices it finds (preferring stable /dev/serial/by-id/ names, which survive re-plugging) and asks which one is the Digitrax controller. Re-running it defaults to the port you already chose.
What the installer does
- Installs Python, and Mosquitto with its client tools, through
apt. - Copies the gateway to
/usr/local/bin/loconet-gatewayand builds its Python virtualenv. - Creates an unprivileged
loconetuser in thedialoutgroup and a config file at/etc/loconet-gateway.env(never overwritten once it exists). - Enables and starts the
loconet-mqttservice, which restarts itself if it stops.
Options
Pass options after -s --:
curl -fsSL https://github.com/LocoPanel/loconet-gateway-releases/releases/latest/download/get.sh | sudo bash -s -- --no-mosquitto --serial-port /dev/ttyACM0--no-mosquitto: don't install Mosquitto; use an existing or remote broker.--local-only: install Mosquitto but keep it reachable from the Pi only.--serial-port /dev/DEVICE: set the serial device and skip the prompt.
Re-running the installer upgrades the gateway in place. To remove it, unpack loconet-gateway.tar.gz from the releases page and run sudo ./uninstall.sh from it. That also removes the Mosquitto listener file.
Letting the app reach Mosquitto
Mosquitto 2.x only accepts connections from the Pi itself by default, so the installer writes /etc/mosquitto/conf.d/loconet-gateway.conf to let other machines on your network connect on port 1883 without a login, and browsers connect over WebSockets on port 9001 (for the web app):
listener 1883
allow_anonymous true
listener 9001
protocol websockets
allow_anonymous true- It's skipped with
--no-mosquittoor--local-only, and when Mosquitto already has a listener on 1883 (the 9001 WebSocket listener is still added if it's missing). - An existing file is never overwritten, so your edits survive upgrades. Re-running the installer on an older install adds the 9001 listener to it.
- Open access is only appropriate on a trusted network. To require a login, replace
allow_anonymous truewith apassword_fileline, restart Mosquitto (sudo systemctl restart mosquitto), and enter the same credentials in the gateway config and the app.
Configure the gateway
Defaults work for a single Pi running its own Mosquitto. To change anything, edit /etc/loconet-gateway.env (uncomment a line and set it), then restart:
sudo nano /etc/loconet-gateway.env
sudo systemctl restart loconet-mqtt| Variable | Default | What it does |
|---|---|---|
LOCONET_SERIAL_PORT | /dev/ttyACM0 | Serial device of the Digitrax interface. The installer sets this for you. |
LOCONET_BAUD_RATE | 57600 | Serial baud rate. |
LOCONET_MQTT_HOST | localhost | MQTT broker the gateway talks to. |
LOCONET_MQTT_PORT | 1883 | Broker port. |
LOCONET_MQTT_USER / _PASSWORD | (none) | Broker credentials, if your broker needs them. |
LOCONET_CMD_TOPIC | track/cmd | Commands in: turnouts, detector refresh and power cycle. |
LOCONET_STATUS_TOPIC | track/turnout/status | Turnout positions out. |
LOCONET_BLOCK_TOPIC | track/block/status | Block occupancy out. |
LOCONET_POWER_TOPIC | track/power/status | Track power out (retained): on, off, epo or unknown. |
LOCONET_AVAIL_TOPIC | track/gateway/status | Gateway online/offline (retained). |
LOCONET_QUERY_SENSORS | 1 | Ask every detector to report when the serial port opens. Set to 0 to skip the ten-second query. |
LOCONET_SENSOR_QUERY_GAP | 1.25 | Seconds between those detector queries. |
LOCONET_LOCO_TOPIC | track/loco | Prefix for locomotive state out (track/loco/status/<address>, retained). |
LOCONET_QUERY_SLOTS | 1 | Read every locomotive slot when the serial port opens, so the app can list the locos on the track. |
LOCONET_SLOTS | 120 | How many slots the command station has (a DCS52 has 120). |
LOCONET_SLOT_QUERY_GAP | 0.1 | Seconds between those slot reads. |
LOCONET_LOCO_REFRESH | 30 | Seconds between resending a held loco's speed to keep its slot from timing out. |
LOCONET_LOCO_TIMEOUT | 30 | Seconds without any LOCO command before held locos are stopped (0 = never). |
LOCONET_LOG_LEVEL | INFO | Log verbosity. |
Connect the app
Click the gear icon in the top bar to open MQTT Broker settings.
- Host and port: the Pi's address and the broker port (1883 by default).
- Use TLS: turn on if your broker uses TLS, usually on port 8883.
- Username and password: optional; only if your broker requires them.
- Command, turnout status and block status topics: leave these at the defaults unless you changed them in the gateway config. Reset topics to default restores them. Clear the block topic to turn block status off.
- Power-cycle track to read blocks: on by default. Block detectors such as the BDL716 only report when a block changes, so after connecting, if some blocks are still unknown the app switches track power off and on once so they report. This stops every train; turn it off here if you'd rather not. See Troubleshooting.
Loco Panel 2.0 and later need gateway 2.0 or later; driving locomotives needs gateway 2.1: commands now go to track/cmd. Update the gateway with the installer first, then the app.
Choose Save & Reconnect. The dot beside the host in the top bar shows the link state:
- Green: connected to the broker and the gateway can reach LocoNet.
- Amber: connected to the broker, but the gateway is offline or can't reach LocoNet.
- Orange: connecting.
- Grey: disconnected.
- Red: connection error.
Commands are only sent while the dot is green, so the panel never claims to have thrown a turnout it couldn't reach. On connect, the app asks the gateway for every turnout's position and every detector's state so the panel matches the layout.
Web app
You can also run Loco Panel in a browser, with nothing to install: app.locopanel.com. It's the same app as the desktop and mobile builds. Your layout and settings are kept in the browser.
Browsers can't open a plain MQTT connection, so the web app talks to Mosquitto over WebSockets. The gateway installer sets up a WebSocket listener on port 9001 for you. Open the web app's MQTT settings and enter the Pi's address with port 9001 and TLS off.
If you used --no-mosquitto or --local-only, or run your own Mosquitto, add the listener yourself:
sudo tee /etc/mosquitto/conf.d/loconet-websockets.conf <<'EOF'
listener 9001
protocol websockets
allow_anonymous true
EOF
sudo systemctl restart mosquittoWhy it's plain HTTP
A page loaded over HTTPS isn't allowed to open an unencrypted ws:// connection, which is what a Mosquitto on your home network offers. So this one address is served over plain HTTP, on purpose. The connection goes straight from your browser to your own broker; nothing passes through us.
- Some browsers warn about
http://addresses. Choose to continue. This address doesn't offer HTTPS, so a browser that tries it first falls back tohttp://. - Browsers may refuse to store the broker password on a non-HTTPS page, so the web app works best with a broker that needs no login.
- It can't be installed as an offline app.
- Use it on a trusted home network. For anything else, use the desktop or mobile apps.
Import your layout
Click the upload icon in the top bar and choose a Layout Editor XML file exported from JMRI or AnyRail. The layout is remembered between launches.
- Turnouts, track, and the detection blocks with the track assigned to them are imported.
- If some pieces couldn't be placed, the import message tells you how many were skipped. Slips, turntables, and double crossovers stored as a single turnout aren't supported yet.
- Name your turnouts and blocks with the address first (naming rules). AnyRail exports usually have no numbers in their names, so IDs start blank and you fill them in on the table.
Turnout and block IDs
The app and the gateway agree on turnouts and blocks by number. Loco Panel takes that number from the start of each name, so name things in your layout editor with the LocoNet address first.
| Name in JMRI / AnyRail | ID Loco Panel uses | Means |
|---|---|---|
5 Yard Lead | 5 | Turnout 5: sends 5:T / 5:C |
12 Crossover | 12 | Turnout 12 |
6 Outer North | 6 | Block 6: listens for 6:1 / 6:0 |
B_6_Outer North | 6 | Block 6 (JMRI's B_6_ form also works) |
Yard Lead | (blank) | No number, so no address: set one on the table |
- One number per turnout. Give every physical turnout its own number, and make sure no two decoders on your LocoNet are set to the same address. The only time turnouts should share a number is when one decoder address really drives several turnout objects, such as the four legs of a double crossover (see below).
- One number per block. Two blocks with the same ID both follow the same occupancy messages, so they light together.
- Turnout numbers and block numbers are separate. Turnout 5 and block 5 don't clash with each other. But a turnout decoder such as the DS54 also reports turnout N's position as sensors 2N−1 and 2N, so a block detector at one of those sensor addresses will appear to change when that turnout moves. Pick block addresses outside that range.
You can fix any ID afterwards: open the table with the table icon in the top bar. It has a Turnouts tab and a Blocks tab.
Turnouts
A turnout's controller ID is the address used on the wire: <id>:T to throw and <id>:C to close. It's filled in from the number at the start of the turnout's name (2 Inbound gets 2), and you can edit it.
- Turnouts that share an ID are thrown and tracked as one unit. A double crossover made of four turnout objects driven by one physical address gets the same ID on all four, and tapping any of them throws all four.
- A turnout with no ID shows a message when tapped instead of sending anything, so unmapped turnouts are obvious.
Blocks
A block's ID comes from the number at the start of its name (6 Outer North gives 6; JMRI's B_6_Outer North form also gives 6) and is editable on the Blocks tab. It should match the LocoNet sensor address of the detector for that block. The ID may also be the block's JMRI system name, such as IB6.
Run your railroad
Switch views with the view button in the top bar. All three show live turnout and block state.
2D
Your track plan. Tap a turnout to throw or close it.
3D scene
The same layout in three dimensions, with turnouts and signals on your own track plan.
CTC panel
A control-machine style panel with a rack of numbered levers. Position levers first (Normal or Reverse), then press Code Start to send them all together, or cancel to clear pending moves.
Track in an occupied block is drawn red in every view, and the CTC panel adds a lamp for each block. On the CTC panel a red lamp means a lever move is staged but not sent yet.
Emergency stop (EPO)
The big red EPO button is on every view (at the end of the lever rack on the CTC panel). It acts the moment you touch it, with no confirmation: it cuts track power at once and keeps it off, and the gateway refuses to switch it back on by itself, even for the block refresh described above, until you restore it.
Whenever track power is off, whether from an EPO or because someone pressed the power key on a throttle, the button turns green. Tap it, and confirm, to switch power back on. The app shows the real power state, read from the layout, so it stays right however the power was changed.
The button works through the gateway, the broker and your network. If any of them is down it says not sent instead of pretending. It is a convenience, not a replacement for your throttle's power off or a hardware stop.
Drive locomotives
Tap the train button in the top bar to open the throttle. It floats over any view, so you can drive while you watch the layout, and you can drag it by its header to wherever suits. It is not modal: the EPO button stays reachable.
- Pick a loco. The list shows every loco the command station has in a slot, whoever is driving it. Type an address and press Take to add one that isn't listed, and use refresh to read the command station again. Tap the star on a loco to make it a favorite; favorites are kept at the top of the list and remembered on that device.
- Drive. Turn the knob (or scroll over it, or use the plus and minus keys) to set speed from 0 to 126, and use the direction switch to reverse. The display shows the address, speed and direction. STOP brings the speed to zero; E-STOP stops the loco at once.
- Functions F0 to F28. The keys are in banks of ten. F0 is Lights, F1 Bell and F2 Horn; the Horn is held, so it sounds only while you press it. Press the pencil to rename keys, then tap one to give it a name (the key picks a matching icon) and to choose whether it is held or switches on and off with each tap. Names are saved per loco on that device.
- Release. Press Release when you finish; the loco stops and its slot is freed for other throttles.
The gateway looks after the locos it holds. It keeps their slots alive, and if it stops hearing from the app for 30 seconds (the app is closed, put in the background or loses the network) it stops them by itself. The EPO button stops them too. As with EPO, the throttle goes through the gateway, the broker and your network, and says not sent if any of them is down.
MQTT reference
These are the defaults. Any MQTT client can use them, which is handy for testing or for your own automation.
| Direction | Topic | Payload | Meaning |
|---|---|---|---|
| App → LocoNet | track/cmd | 42:T, 42:C, 42:Q | Throw, close, or report the position of turnout 42. |
| App → LocoNet | track/cmd | Q | Ask every detector to report its state again (no turnout number). |
| App → LocoNet | track/cmd | BLOCKS 100-115 | Which sensor numbers are block detectors. The app sends this from its block table whenever it connects. |
| App → LocoNet | track/cmd | BDL 100 | Read (never write) the options of the BDL716 whose base address is 100. The answer is published on track/bdl/100/settings and logged. Needs track power on. |
| App → LocoNet | track/cmd | RAW BB 00 00 44 | Diagnostics: send one LocoNet query frame (checksum checked; only slot-read and switch-state queries are accepted) and log every frame heard for three seconds. |
| App → LocoNet | track/cmd | EPO | Emergency power off: cut track power at once and keep it off, even against a power cycle, until RESTORE. |
| App → LocoNet | track/cmd | RESTORE | Switch track power on, clearing an emergency stop if one is latched. |
| App → LocoNet | track/cmd | SLOTS | Read every locomotive slot of the command station (read only). Also done when the serial port opens. |
| App → LocoNet | track/cmd | LOCO 3 | Take the loco with address 3. |
| App → LocoNet | track/cmd | LOCO 3 S 64, LOCO 3 D F, LOCO 3 D R | Set loco 3's speed (0 to 126), or its direction (forward or reverse). |
| App → LocoNet | track/cmd | LOCO 3 F0 1, LOCO 3 F2 0 | Switch function F0 to F28 of loco 3 on or off. F9 to F28 are DCC packets, so the gateway keeps their state itself. |
| App → LocoNet | track/cmd | LOCO 3 ESTOP, LOCO 3 REL | Stop loco 3 at once, or stop and release it. |
| App → LocoNet | track/cmd | LOCO KEEPALIVE | The controller is still there. Without any LOCO command for LOCONET_LOCO_TIMEOUT seconds the gateway stops the locos it holds. The app sends this every few seconds while it holds one. |
| LocoNet → App | track/loco/status/<address> | JSON | Retained state of every loco in a slot, kept current from every throttle on the track: address, slot, status (in-use, idle or common), speed, estop, forward, functions F0 to F28, and owned (this gateway holds it). Cleared when the slot is freed. |
| LocoNet → App | track/power/status | on, off, epo, unknown | Track power as the layout reports it (retained); epo while an emergency stop is latched. A gateway restart clears the latch. |
| LocoNet → App | track/bdl/<address>/settings | JSON | A BDL716's options: sensitivity (OPSW 1, 2), detection speed (OPSW 3) and whether it reports occupied when track power is off (OPSW 15), plus the raw CVs. |
| LocoNet → App | track/turnout/status | 42:T, 42:C | Turnout 42 is thrown or closed. |
| LocoNet → App | track/block/status | 42:1, 42:0 | Block 42 occupied or clear (from LocoNet occupancy reports such as a BDL16x). |
| Gateway | track/gateway/status | online, offline | Retained. online only while both the broker and the LocoNet serial port are up. |
In the app, block messages are <blockId>:<state>. Occupied can be written O, OCC, OCCUPIED, 1, ACTIVE or ON; clear can be C, CLEAR, FREE, 0, INACTIVE or OFF.
Try it from the Pi:
mosquitto_pub -t track/cmd -m 5:T
mosquitto_sub -t track/turnout/status
mosquitto_sub -t track/block/statusTroubleshooting
First, check the service and its log on the Pi:
systemctl status loconet-mqtt
journalctl -u loconet-mqtt -f- The dot is amber
- The app reached the broker but the gateway reports it can't reach LocoNet. Check the Digitrax unit is powered and plugged in, and that
LOCONET_SERIAL_PORTis the right device.ls /dev/serial/by-id/lists what's connected. - The dot is grey or red
- The app can't reach the broker. Check the host and port, that Mosquitto is running (
systemctl status mosquitto), and that it has a listener for other machines (the installer adds one unless you used--local-only; see Install the gateway). A firewall on the Pi can also block port 1883. - Tapping a turnout shows "No controller ID mapped"
- Give that turnout an ID on the Turnouts tab of the table.
- Blocks show occupied that shouldn't be
- Turnout decoders report positions as sensors 2N−1 and 2N, which look like occupied blocks. Put your block detectors at addresses outside that range.
- Blocks are wrong right after a restart
- The gateway queries every detector when the serial port opens. That takes about ten seconds, and block state is current once it finishes.
- BDL716 blocks stay unknown, or an occupied block doesn't show
- A BDL716 only reports a block when it changes, and ignores the detector query, so a block that is already occupied says nothing. The fix is the track power cycle (the app does it for you once, if blocks are unknown): with the board's default settings (OPSW 15) it reports every block occupied when power drops, and the clear ones again when it returns. The gateway publishes any block it knows is a detector but heard nothing from as occupied, and keeps each block's last state, so later connections and the app coming back from the background are current. The gateway learns which sensors are detectors from the block IDs in your block table, which the app sends each time it connects, and keeps that list in
/var/lib/loconet-gateway/blocksso it survives a restart (delete the file to fall back toLOCONET_BLOCKSin the gateway config). To check a board's settings, publishBDL 100(its base address) totrack/cmdand read the answer ontrack/bdl/100/settings. - Nothing happens when I change the gateway config
- Restart it:
sudo systemctl restart loconet-mqtt.
Release notes
The app and the gateway are numbered together, but a release of one doesn't always need the other, so their latest versions can differ. The full list for each version is on the app and gateway releases pages.
2.1.2: stylized crossovers
- Stylized CTC view. A double crossover now draws as a clean X between its two tracks, instead of having some of its legs folded onto the straight track.
- Gateway: no change, so it stays at 2.1.0.
2.1.1: crossovers and the keyboard
- Double crossovers. A layout file that describes a crossover as one JMRI double crossover now shows all four of its tracks, with one dot in the middle. It is thrown as a unit, like a crossover built from four turnouts. Give all four of its legs the same controller ID in the turnout table.
- Arrow keys on the CTC panel. Left and Right scroll the lever rack a lever at a time, Page Up and Page Down a screenful, and Home and End jump to the ends. Click anywhere on the panel first if the keys stop responding.
- Gateway: no change, so it stays at 2.1.0.
2.1.0: locomotive control
- Throttle. A floating panel over any view: pick or take a loco, turn the knob, set direction, STOP and E-STOP, and release. Drag it by its header to move it. More
- Functions F0 to F28. F1 is Bell and F2 is Horn, held while pressed. Every key can be named and set to held or toggle, per loco.
- Favorites. Star a loco to keep it at the top of the list.
- Gateway 2.1. Reads every locomotive slot, publishes each loco's state, and takes
LOCOcommands to drive them. It keeps held slots alive and stops held locos on an emergency stop or when the app goes quiet for 30 seconds. The app needs gateway 2.1 to drive locos; everything else works with 2.0.
2.0.0: gateway 2.0
- Block occupancy that survives the app going to the background, and an optional power cycle to read blocks.
- The EPO button and live track power, on every view.
- New 15-block layout and a tidier stylized CTC diagram, with block lamps in the middle.
- One command topic,
track/cmd, so the app needs gateway 2.0 or later.
Signal Board
The Signal Board is a driver board for trackside signals: 32 four-aspect signals (red, yellow, green and lunar) from an ESP32 that listens for turnout state over MQTT. It's still in development, so there's no setup guide yet. Get in touch to hear when it's ready.