Model Railroading

December 28, 2025

This year I decided to try out model railroading as a hobby. I figure I’m old enough at this point, and it’s a great intersection of my other hobbies (small scale custom electronics, benchtop metal working, and 3D printing). What pushed me over the edge was our old, boring, unreliable toy train that ran in a circle under the Christmas tree. It never ran well, often got stuck on branches or ornaments, and constantly got in the way of gifts. This felt like a great excuse to go overboard in “solving” a problem.

Getting started, I knew I wanted some kind of kit, so that I didn’t have to figure out every decision in advance. I figured I could start there and expand. I also knew that computer control was a non-negotiable for me. If this hobby didn’t lead to writing code, what good was it?

At some point in the process of getting into model railroading you need to consider which scale you want to work in. There are lots of pros/cons, but in the end I decided on HO (Half O) scale. It hit the sweet spot for me, balancing price, availability, space constraints, and so on.

I also knew that I’d want to really be able to hack on this, if it was going to be fun for me. Some research led me to DCC, and I knew I needed a DCC ready set if I was going to enjoy this.

I ended up with a Bachmann Trains Digital Commander kit. (Note: at the time of writing the price is 25% more than I paid just a few weeks ago. I’m not sure if I got lucky or it something else is going on.) This kit was exactly what I was looking for. It came with enough track to make a layout the size I wanted. All the track is Backmann’s EZ-Track style, in which the ends of each piece slot/click together. And the locomotives and cars it comes with are attractive and well built.

It also comes with an “E-Z Command Digital Control System,” which is a hardware control panel that lets you program and control your Cabs on the layout. The setup is not particularly intuitive, but the instructions were well written and I was able to setup my train quickly and easily.

While I was waiting for the train kit to arrive, I went to the hardware store and purchased some lumber and built a basic platform for the layout to sit on. My plan was to place our Christmas tree in the center, and have the train drive around the top, around the tree. In the end I’m very happy with how the table came out. The size ended up perfect for our space, with enough height underneath for storing gifts.

As soon as I played with the hardware control panel I knew I needed a digital controller I could code against. There was just no way I was going to be satisfied with having to manually play with the controls every time. (Which might make me an outlier in this hobby. It seems that manual control is the point for lots of hobbiests.)

I landed on a DCC-EX controller, because it seemed to strike the balance I was looking for in capability/complexity. I could have tried to build my own, but I wanted to get running quickly, and wasn’t going to get much fun out of building an electronics kit and running code already built. So, I bought a pre-built kit.

The DCC-EX was easy to get connected. I had to cut/strip the wires from the Bachmann controller, and then plug it all in. The setup process involves connecting to a WiFi AP that the DCC-EX broadcasts, then changing some settings.

After getting the DCC-EX connected to my home wifi, I had to figure out how to send commands to it. I started with an app from the App Store, just to make sure everything was working. Sure enough, after connecting to the IP Address of my controller, I could adjust the throttle and toggle the light on my cab with no problem.

Figuring out how to send commands from my own code took a bit longer, as the documentation wasn’t clear about how to connect over WiFi. In the end it was as easy as opening a TCP connection to the default port and sending text.

(I got really hung up at this point by some stupid MacOS security restrictions on connecting to devices on a local network. I couldn’t get anything to work in iTerm. When I finally tried in Terminal.app everything worked flawlessly. After some amount of debugging I was able to get iTerm working again.)

Step one was to be able to send a few commands to start, stop, speed up, slow down, etc. That was easy enough, and I put together a super basic set of scripts to run that for me.

But what I really wanted was a fully automated layout, where the Cab speeds up and slows down based on which sector it’s in. And for that, we were going to need sensors.

My first attempt at detecting Cab location tried hall effect sensors. These cool devices are able to detect the presense of a magnetic field. Hooked up to a basic microcontroller, and you can tell when a magnet is nearby. Put a magnet under your rolling stock, and you can detect when the train comes by. At least, that’s the theory.

In practice the effective range of the sensors I bought was just way too small. I did some research, and while I probably could have figured out a way to get hall effect sensors working, it was all much less reliable than I wanted.

For my second attempt, I went with Infrared Reflection sensors. These little devices put an IR emitter side-by-side with an IR sensor, divided by a thin piece of plastic. When an object comes nearby, the reflection is brighter, and the sensor can “detect” an object being close. The sensors I got had both a tunable digital output pin, as well as an analog output that allows you to view the raw voltage coming off the sensor, which lets you tune it in software.

I hooked up the sensor to an ESP32 (I’m fond of these Feather boards from Adafruit, but any ESP32 dev board would have worked), and — voilà! — I could get real-time notifications when my train crossed sector boundaries.

All in all I setup 3 IR sensors wired to a single ESP32 board, which read the incoming data, computed a rolling average, and posted it once per second to my primary controller.

Oh, right, the controller! Being the crazy person that I am, I expanded my server code into a full-on Ruby gem that coordinates the activity on the layout automatically. It runs a server that can receive info from clients (everything from data updates from proximity sensors to status requests from the TUI), and send commands to the DCC-EX controller.

Once everything was in place and communicating properly, I was able to sit back and watch as the Cab trundles around the bend, picks up power to make it up the hill, and then dials it back as it comes down the hill.

Now that I’ve managed to dip my toes into this hobby, I have a million ideas for how to improve this layout. I’d like to completely redo the terrain around the track layout I came up with. A redo would include better mountains/hills, a ridge, a tunnel, and better handling of the inclines and declines for the tracks. Oh, and more and better trees!

After that, perhaps I can acquire a warehouse for some real expansion…


December 28, 2025

When I switched from Terminal.app to iTerm2 I had a noticeable decrease in battery life on my laptop. Trying out Ghostty now to see if it’s any better.


Robin Sloan's newsletter is always such a treasure. October's Edition is no exception. And so many g

October 17, 2025

Robin Sloan’s newsletter is always such a treasure. October’s Edition is no exception. And so many great links!


It's great that remote MCP has kick-started a new wave of open and easy APIs for lots of services, b

August 03, 2025

It’s great that remote MCP has kick-started a new wave of open and easy APIs for lots of services, but JSON RPC, really? Did we learn nothing from the SOAP era? Bog standard HTTP was right there. SMH

Why must we repeat our mistakes like this?


Interesting side effect of our engineers building rules files for Claude Code is that we have an exc

July 08, 2025

Interesting side effect of our engineers building rules files for Claude Code is that we have an excellent, concise set of our own coding styles, patterns, and preferences now — the best one we’ve ever had, in fact.

The best development practices are more valuable than they’ve ever been.


Got frustrated by OpenAI Codex not working (was probably user error on my part), and thought, "How h

June 15, 2025

Got frustrated by OpenAI Codex not working (was probably user error on my part), and thought, “How hard could it be to make one of these things?”

Turns out, not that hard(ish).

This weekend I built ‘genie’, a cli coding agent written in Ruby: github.com/jeffmcfad…


GenAI can be so incredibly useful and powerful in contexts where information/best practices are wide

May 06, 2025

GenAI can be so incredibly useful and powerful in contexts where information/best practices are widely known and disseminated but potentially tricky to apply to a specific use-case.

I had an incredible ChatGPT session yesterday applying some Deep Work / Focus / Strategy concepts to specific situations at work. Left with some concrete next-steps for myself plus a bunch of new concepts to research more.


Oh this is so good.

May 05, 2025

Oh this is so good.

alex.party/posts/202…


If you are replacing great engineers with AI, please let me know.

April 30, 2025

If you are replacing great engineers with AI, please let me know.

We’d love to hire those great engineers!


Today I discovered Pandoc. My life will never be the same.

April 29, 2025

Today I discovered Pandoc. My life will never be the same.

pandoc.org


Absolutely rooting for Yuki this weekend.

April 03, 2025

Absolutely rooting for Yuki this weekend.


> What’s particularly ironic is that today’s Google has become exactly what its founders warned agai

March 30, 2025

What’s particularly ironic is that today’s Google has become exactly what its founders warned against in their 1998 paper: an advertising company whose business model fundamentally conflicts with serving users’ needs.

“The Mediocrity of Modern Google” om.co/2025/03/2…

The Gemma 3 models are just crazy good for their size.

March 26, 2025

The Gemma 3 models are just crazy good for their size.

Apple should be partnering with Google to provide these models for their on-device usage.


Not sure how it is that I hadn’t come across this (ReAct / Thought, Action, PAUSE, Observation) befo

March 26, 2025

Not sure how it is that I hadn’t come across this (ReAct / Thought, Action, PAUSE, Observation) before today, but it suddenly made some Gemma 3 experiments I was playing with tremendously more reliable.

LocalLLMs are fun!


For me, the act of writing code provides a certain kind of feedback mechanism, helping me gauge how

March 03, 2025

For me, the act of writing code provides a certain kind of feedback mechanism, helping me gauge how well I truly understand the problem I’m trying to solve. Increased friction/resistance in finding the best solution in code means I’m out of phase with the problem in some way, and need to think on it more. Code generation tools modify or eliminate that feedback loop, and I find that disorienting at best.


It's always great when present me gets to thank past me for taking notes (and putting them into the

February 19, 2025

It’s always great when present me gets to thank past me for taking notes (and putting them into the readme) on how to debug some library I made overly complicated.


Being able to run LLMs locally is really, really cool. Once products catch up with the functionality

February 15, 2025

Being able to run LLMs locally is really, really cool. Once products catch up with the functionality available there are going to be some really cool use-cases.


"The hardest working font in Manhattan"

February 15, 2025

The hardest working font in Manhattan

What a fun deep-dive into this old, seemingly ubiquitous and hard-working font. Exactly the kind of thing Blogs are best at.


Pro Tip: If you're going to use ChatGPT during your tech interview...

February 04, 2025

Pro Tip: If you’re going to use ChatGPT during your tech interview…

  1. Don’t do that.
  2. Maybe don’t make the mistake of sharing your screen with ChatGPT on the top window, and read the answers verbatim.

This interview with Ted Chiang is so, so good.

February 02, 2025

This interview with Ted Chiang is so, so good.

lareviewofbooks.org/article/l…