Model Railway Computer Control

There are many different ways to add computer control to your layout. It is very easy to start off even with something small such as controlling street lights. This page is intended to be the starting point for anyone interested in trying out computer control.

Ways you can start out with computer control:

  • Controlling street lights or station platform lights
  • Controlling building lights (such as LEDs in houses, sheds, station buildings etc)
  • Controlling signals such as those from Train-Tech
  • Detecting trains
  • Combining signal control and train detection for automatic signaling
  • Using train detection with level crossing lights

As you learn how to add these elements to your layout, you can build up to more ambitious projects such as automatically controlling trains and setting up automated routes (shuttle). This can be done with both DC and DCC. You don't need any expensive specialized hardware you can do it with off-the-shelf commodity electronics that you can buy straight off Amazon or eBay for just a couple of pounds (or dollars).

Web based control

All of the projects we will show you in this series of articles and videos revolves around what we call "web based control". This basically means you can use your phone or tablet or computer to control your layout by simply using the web browser. All of the projects we will show you use what is called a web based API, this simply means that all of the functions can be carried out by URL such as:

http://signal-box-light.local/api/1/lights/off

http://level-crossing.local/api/1/active

This allows us to create a very modular system but also makes it easy for you to test out what you have added to your layout. Each module is a building block that when used together can do very powerful things like control signals, sounds and level crossings automatically as the train travels through your layout.

Part 1: Which boards to use and when to use them

You have to start somewhere right? In this first video, we introduce you to a couple of different types of boards and explain where they are best used. Have a look at the video and then check out the additional information below.

Useful Software

Arduino - Software
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
oorail/oorail-system
Open Source Digital Model Railway / Train Control System - oorail/oorail-system
oorail/arduino-rail
Educational Model Railway Projects using the Arduino Platform - oorail/arduino-rail

Other useful software includes Raspbian which is a Debian based Linux platform for the Raspberry Pi. You can find useful tools for writing this to SD card over at the Raspberry Pi Downloads.

GPIO pins

GPIO standards for General Purpose Input Ouput. These pins on a microcontroller are used for general purpose digital i/o. They are not defined by default and instead can be controlled by user programming. On some devices, some of the pins are multi-purpose, so a particular pin might be configurable for GPIO and TOUCH, or GPIO and ADC (analog to digital converter). This basically means you can use the pins for whatever your application needs to use them for.

Arduino Microcontroller

The Arduino is a series of microcontrollers that vary in the number of digital i/o and analog i/o pins they have available for programming. These pins are used to communicate with external devices such as sensors, lights or relays to perform a task or gather information. The Arduino modules typically run at about 16MHz and have EEPROM, FLASH and SRAM for memory storage. Each of these is typically a small amount (we are talking bytes and kilobytes not megabytes). These boards are typically programmed to do one or two specific tasks, basically gather information or control something. You would typically use these boards in unison with something like an ESP32 or ESP8266 which might control several of these boards and provide a web interface into the system.

ESP8266

The ESP8266 is a system-on-a-chip device that operates at either 80MHz or 160MHz. It has a 32-bit RISC processor, the L106 based on the Tensilica Xtensa Diamond Standard 106Micro. Some ESP8266 modules have problems with WiFi and give off a lot of heat at 160MHz. The speed option is programmable at boot time. A lot of our projects will use the default settings for this, so you should consider most ESP8266 projects from oorail are running at 80MHz. The ESP8266 has built-in WiFi capability and can easily host a simple asynchronous web server. The ESP8266 has only one processor core and 80K of user-data RAM. The ESP8266 has 32K of instruction ram and 32K of instruction cache. It has 16K of system-data ram. The ESP8266 can work with up to 16MB of flash, however its typically packaged with 512K to 4MB of flash.

ESP32

The ESP32 is a system-on-a-chip device that operates at either 160MHz or 240MHz. It has a 32-bit Xtensa LX-6 processor. This processor is typically dual core but there are single-core versions of the ESP32. There are three versions of the ESP32 available currently that have dual-core processors. The single core version has the identifier "ESP32‑S0WD", so unless you have a specific ESP32 application where you want to use the single core version, you want to avoid purchasing ESP32 modules with this identifier.

The ESP32 module has 520K of SRAM, built in WiFi and Bluetooth and host of other integrated devices. This diagram provides a look at the ESP32 capabilities:

ESP32 block diagram

Raspberry Pi

The Raspberry Pi is a Single Board Computer (SBC), the current version is the Raspberry Pi, 4 which runs at 1.5GHz and is a 64-bit Quad-Core ARM Cortex A72 processor. It comes in 1GB, 2GB and 4GB versions. It is a full blown computer that boots from micro SD card and runs the Linux operating system (ARM architecture). The Raspberry Pi can be used with touch screens to create control panels, used as a central computer or even as a desktop replacement.

Where to buy components

If you are ready to get started you can buy modules from a variety of places, we would recommend that you check out the specific project you are looking to follow. Each of the projects have their own parts lists as we release them.

However if you are just looking for general ESP32, ESP8266, Raspberry Pi or Arduino modules you can check out the current lists we have at our Amazon Shop:

For those residing in North America:

https://www.amazon.com/shop/oorail.com?listId=2Z1JTH5TNSRM5

For those residing in the United Kingdom:

https://www.amazon.co.uk/shop/oorail.com?listId=G7YJU1JLW9HL

Other Resources

Here are some of our other related computer control articles and pages...

Computer Controlled Trains
This video gives a brief introduction and a demonstration of a new Digital Model Railway control system called Digital DC (DDC). The DDC control system is FREE to download and the source code is available under the GPLv3 Open Source License. Digital DC (DDC) enables train control via a Web (HTTP) …
Digital DC Power Supply
In this video we show you how to use off the shelf power supply units to create a highly reliable power supply for your digital DC (DDC) controller, layout electronics and accessories. We also take a quick look at DIN rail mounting that is used in industrial and telecommunications systems, and how i…
Digital DC Project (DDC)
Next Generation of Digital Train Control Welcome to the Digital DC (DDC) Project. DDC is a new model railway control system built using off-the-shelf DC powered electronic components and modules. The software that enables the DDC system is available to download for FREE [https://github.com/oorail/oorail-system/releases…