Smart Train Tracks for O gauge model train


I am kind of new to Arduino and electronics. I am a software professional and have a fair idea about C language. I am 3D print hobbyist. I have basic knowledge of electronics.

Recently, I purchased Alaska Freight Lionchief set O gauge model. Power to the train is supplied through the tracks. I am trying to build now 3D printed custom train tracks for the train. I need some advice on how I can design my track system with Arduino.

I am planning to use ARduino nano 33 IOT for this project .

Track system will have below features:

  1. All tracks will have 4 LED lights. I want to control LEDs through ARduino. Arduino should be able to switch off lights for individual tracks.
  2. MY 3D printed tracks will be set of either small straight or curved tracks with maximum length of 10 inches. Each track will have three rails made of conductive material. Power to the train will be supplied through tracks (middle track is +18v and outer two tracks are ground.). I am basically replicating the same power delivery system that came with original train set. I do not have to worry about the power supply adapter because I will use the existing one.
  3. Each individual track can be taken out of the power delivery system so that one particular section of the track system will go out of power. This is to stop a train in that section only. However, other trains running on same track on other sections will not be affected due to power loss in one track. I plan to use relay to cut the power supply to middle track through Arduino.
  4. I plan to add a sensor on each track to detect whether the track has train running on it. Idea is, Arduino should be aware of where is the train running. I will probably use color detectors to use this.

For above requirements, I am trying to figure out what ICs and bus system I should. In total, I need to build 72 such individual tracks so I am sure that I need at least 7 bit address system to identify individual tracks.
Problem which I am facing is:

  1. What bus system I should use? - I am trying to explore I2C bus system but I am not able to figure out ICs which will go on individual tracks
  2. Two way communication is needed - A) from Arduino to individual tracks - to turn off power supply or control LED lights B) Tracks to Arduino - to indicate if current track has train running on it.

I was thinking to use 8 bit shift register to control LEDs. But this approach require lot of bus running through all tracks unnecessarily. Same problem persists if I try to read track input through shift register.

Any advice on how should i address these problems?

Wouldn’t it be much more realistic when you move the electronics into the train? This way the train has power to control lights but can start and stop the motor depending the position.

You also likely have more tracks than trains and therefore need less electronics, less things that can go wrong.

You indicate that you want 4 leds per track, is this per piece of track and where will these leds be located?

Have you looked at DCC - as this is a standard for model trains and uses the track as a bus. It allows many individual components to be addressed and controlled.

There are various sites detailing how to use an Arduino to control the various parts.

@Klaus_K : Thank you for suggestion. I agree it is too much work. But I will have to do the same unless I find some API given by Lionel to control the train. When I will create my own 3D printed locomotives and other train cars then i will have the liberty to move all electronics into the train.

@countrypaul - Yes, 4 LEDs will be on each track. This is good to know. I will check what is DCC and whether I can use that to control the train

The protocol for controlling Lionel TMCC and Legacy locomotives is published and easy to achieve.

Unfortunately the Lionchief protocol is not documented, but someone has reported decoding it here.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.