Electronics Wiring & Dcc

Infrared Model Train Detection for Block and Station Sensing

How infrared model train detection works, from reflective sensors like the QRD1114 to break-beam pairs, with placement, wiring and troubleshooting tips.

On this page
  1. What Train Detection Does
  2. Two Main Infrared Methods
  3. Choosing Between Them
  4. Where to Place Sensors
  5. Wiring and Interface
  6. Common Problems and Fixes
  7. Detection and DCC
  8. Frequently Asked Questions

What Train Detection Does

Train detection tells a control system where trains are. That information can switch signals, stop a train at a station, start a sound, or feed a computer or microcontroller that runs automated operation. Detection methods fall into a few groups: current sensing (detecting current drawn from a section of rail), magnetic or reed sensors, and optical sensors, including infrared.

Infrared (IR) detection does not depend on electrical contact with the locomotive’s wheels, so it works with rolling stock that draws no current, such as cars with no lights. That makes it well suited to detecting a whole train rather than only powered locomotives. It does require careful setup because IR sensors respond to ambient light, surface color and distance.

Two Main Infrared Methods

Reflective sensors

A reflective sensor places an infrared LED and a phototransistor side by side in one package, facing the same direction. The LED emits infrared light and the phototransistor measures how much bounces back. A passing car increases the reflected light and the sensor’s output changes.

A commonly used part is the QRD1114 (and similar QRD1113). Its datasheet describes it as a short-range sensor, working at distances of around a centimeter or less. Hobbyists use these because they can be mounted flush between the rails or in the roadbed, with nothing protruding beside the track. In N scale, where space is tight, this is a common reason to consider them. Always check the current datasheet for the exact part you buy.

Because of the short range, mounting height matters. Sensors that must look up at the underside of a car may need to be close to the car, and some modelers have found these parts less reliable when the gap is larger. Test on your own track before committing.

Break-beam (transmitter and receiver) sensors

A break-beam system uses an infrared emitter on one side of the track and a receiver on the opposite side. A passing train interrupts the beam. This approach tends to give a clear on or off signal at longer distances, but the parts sit beside the track, which may be awkward in some scenes.

Choosing Between Them

Factor Reflective Break-beam
Mounting Between or under the rails Both sides of the track
Range Short Longer
Sensitivity to car color Yes Less so
Visibility Easy to hide Needs a hidden path on both sides

If nothing may protrude beside the track, reflective sensors are the usual first choice. If the sensors can be hidden in scenery, break-beam may be easier to make reliable.

Where to Place Sensors

  • Block boundaries. Place one sensor at the entry and one at the exit of a block to know when it is occupied.
  • Stations and sidings. A sensor at the stopping point tells a controller when to halt a train or release a signal.
  • Crossings. Sensors on either side of a grade crossing can trigger flashing lights, a bell or a gate.
  • Staging yards. Sensors on each track show which are occupied.

Think about train length. A single spot sensor only detects the point where it sits, so it works best when combined with logic that remembers state, such as “block occupied until the exit sensor fires”.

Wiring and Interface

Typical hobby setups involve a microcontroller board, and sensors connected through resistors sized according to the datasheet. In general:

  1. Power the LED through a resistor to limit current to the datasheet value.
  2. Read the phototransistor with a pull-up or pull-down resistor, either to a digital input or an analog input.
  3. Use an analog reading with a threshold if you need to tune sensitivity, and add some hysteresis to avoid flicker.
  4. Keep sensor wires short or use shielded cable for longer runs.
  5. Power the electronics from a supply separate from the track power, and connect grounds as the design requires.

Because values depend on the exact part and supply voltage, use the datasheet or a trusted application note and test with a multimeter. For layout power and bus wiring in general, see our model railroad wiring diagrams article.

Common Problems and Fixes

  • False triggers from room light. Infrared from sunlight or some lamps can interfere. Shield the sensor, shade the track, or use modulated IR with a matching receiver.
  • Dark or non-reflective cars not detected. Adjust the threshold, move the sensor closer, or use break-beam.
  • Missed detection at speed. Sample the sensor often enough in your software.
  • Flicker between cars. Use a short delay or hysteresis so gaps between cars do not release a block.
  • Dirt on the sensor. Keep the lens clean. Dust and ballast can reduce sensitivity.

Detection and DCC

DCC and IR detection are independent, which is a strength. The infrared sensors work whatever control system you use, and they can be tied to DCC accessory decoders or to a computer layout program. Some DCC systems also include occupancy detectors based on current sensing, which have different strengths. If you are choosing a system and want detection later, look at what feedback buses it supports. Our DCC model railroad systems guide discusses what to look for.

Frequently Asked Questions

Is a QRD1114 good for model train detection?

It can work where the sensor can sit very close to the passing equipment, but its short range and sensitivity to ambient light and surface color mean you should test it on your own layout first.

Can infrared detect unpowered cars?

Yes. It senses the car’s body or underside, not its electrical draw.

Does infrared detection work in a bright room?

It can be affected by strong ambient infrared. Shielding and thresholds help, and modulated sensors are more robust.

The complete guide to electronics wiring & dcc

DCC Model Railroad Systems: How They Work and What to Buy
Read the guide

Keep exploring

Guides from other topics

All topics →