Electronics

Every line of our own code that the railroad runs was written by AI. Most of the early code went into getting the layout's radios and the computer to talk.

This is where AI stopped writing documents and started writing things that run. The AI was now working in the same files I was, in an AI code editor, so the result was something I could load onto a board and test, not only something to read.

01The first client

Tool
Cursor
When
August 2025
Status
Done; the base of later work

The job

I wanted to see whether a cheap ESP32 board could talk to JMRI (Java Model Railroad Interface) over MQTT (Message Queuing Telemetry Transport), a lightweight message service, and drive switches, sensors and lights.

What AI did

In about ten days it wrote traincode: over-the-air firmware updates, any pin configurable as a sensor, turnout or light, devices that find each other by name, first-time Wi-Fi setup through the board's own access point, a built-in web page with a control panel, backup and restore of its settings, and automatic reconnection with its state synced again at boot. Every line was written by AI, and the same is true of all the railroad's own code today.

What came out

A working client, and the foundation of the later bridge. The railroad later switched to an Arduino Nano for compatibility with LCOS (Layout Control Operating System), but the ideas carried over.

Verdict
  • Worked well: the speed. That list is weeks of evenings for one hobbyist.
  • Lesson: a quick prototype is worth it even if the hardware changes later.

See it: traincode on GitHub

02The LCOS bridge

Tool
Cursor, later Claude
When
October 2025 into 2026
Status
In service

The job

The switches, detectors and signal lamps are wired to LCOS radio nodes near the track. JMRI has no radio of its own, so something had to pass messages between the two, in both directions, without either side getting confused.

What AI did

It planned and built the bridge in stages. It began as an ESP32 idea built on traincode and became an Arduino Nano on a serial link with a small program on the PC. It started read-only, only listening. Then it became two-way, so JMRI could send commands back. Signals came next. After that it had to cope with JMRI running on more than one computer, and finally with signals that could run on the layout's own logic or be set from JMRI.

What came out

One of the most involved pieces of the whole project, and an open-source bridge that works on any LCOS layout with a JMRI MQTT connection.

Verdict
  • Worked well: growing the bridge one capability at a time, each tested on the layout before the next.
  • Needed me: the hardware on the bench, and deciding who is in charge of a signal at any moment. Getting that hand-over safe took the longest.

See it: LCOS and the Arduino bridge · What we added to JMRI · LCOS_ESP32_MQTT_Client on GitHub

03The wiring inventory

Tool
Cursor, later Claude
When
November 2025 on
Status
Kept current

The job

A railroad that is going to be wired has to know what it is wiring: every switch, signal and detector, which node it hangs on, and which pin.

What AI did

I had a hand-drawn sketch of the layout made of plain typed characters. With Cursor it became a spreadsheet of switches, signals and locations, and then a versioned wiring workbook. That workbook later fed the wiring documents and the website.

What came out

The wiring viewer, which shows each node pin by pin, the layout drawings, and the searchable device viewer.

Verdict
  • Worked well: turning a rough sketch into structured data that many pages can draw from.
  • Lesson: check the inventory against the wires now and then, or it drifts.

See it: Wiring viewer · Layout documentation · Device viewer