Skip to main content

Sensors

Sensors provide real-time detection of train presence, turnout positions, and other physical events on your layout. Sensor data is used to trigger automated effects and update signal aspects.

Sensors list with real-time state

How Sensors Work

Sensors are hardware inputs (typically analog or digital pins on Arduino, ESP32, or Pico W devices) that detect physical changes on the layout. Common sensor types include:

  • Infrared detectors -- Detect train presence in a block by breaking an IR beam.
  • Current sensors -- Detect power draw on a section of track, indicating occupancy.
  • Reed switches -- Activated by magnets mounted under rolling stock.
  • Optical sensors -- Detect passing trains using light sensors.

Sensor-to-Effect Automation

The primary automation feature of sensors is their ability to trigger effects. Each sensor can be linked to an effect. When the sensor's state changes, the linked effect automatically updates to match.

This creates an end-to-end automation chain: a train passes a sensor, the sensor activates, the linked effect triggers (for example, turning on a crossing signal), and the effect runs until the sensor deactivates.

Example: Block Occupancy Signal

  1. Configure an IR sensor on an Arduino board connected to pin A4.
  2. Add the sensor from the Sensors screen (/sensors) and link it to a signal effect.
  3. When a train enters the block, the sensor activates.
  4. The linked signal effect activates too, which changes the signal aspect to red.
  5. When the train exits, the sensor deactivates, and the signal returns to green.

Automations

A sensor's direct link can only drive a single effect. For anything more involved, create an Automation (/sensors/automations) and link the sensor to it instead. An automation fires a sequence of actions when its sensor activates, deactivates, or either:

Action TypeIconDescription
EffectRocketTurns a pin-toggle effect on or off
TurnoutSplitSets a turnout to thrown or closed
SignalTraffic lightSets a signal's aspect (red, yellow, green)
RouteMapRuns a route, throwing every turnout it references
ThrottleSpeedometerSets a throttle's speed and direction

Each automation also supports an optional delay (milliseconds to wait before running its actions) and can be individually enabled/disabled without deleting it. Actions in an automation run sequentially, in the order they're listed.

Real-Time Monitoring

The Sensors screen (/sensors) lists your sensors and displays their data in real time. As sensor states change on the layout, the UI updates immediately. This makes it easy to verify that sensors are working correctly during installation and testing. Add sensors here, and build sensor-triggered rules from the Automations view (/sensors/automations).

When viewing a device's details page (/devices/:deviceId), you can see which sensors are assigned to that device alongside its turnouts and effects.

Sensor Tips

  • Debouncing -- Hardware sensors can produce noisy signals, especially current sensors. Implement debouncing in your device firmware to avoid rapid state toggling.
  • Pin placement -- For IR sensors, position the emitter and detector on opposite sides of the track, below rail height, to reliably detect all rolling stock.
  • Testing -- Use the Cloud app's real-time sensor display to verify sensor wiring before linking effects. Watch the sensor state change as you manually trigger the sensor.
  • Need more than one action? -- A sensor's direct link only drives a single effect. To respond to one sensor with several outputs (effects, turnouts, signals, a route, or a throttle change), create an Automation and link the sensor to it instead.