JMRI® connects to...


Supported Hardware

Devices, command stations, networks, and protocols:


By the community of


JMRI tools for working with your layout:

Layout Automation

Use JMRI to automate parts of your layout and operations:

JMRI Help:
Contents/ Index
Glossary/ FAQ

Donate to JMRI Donate to

DCC++ Sensors

Any Arduino pin can be used as a DCC++ Sensor input.

Indexed DCC++ Sensor Pin Control

Each Sensor pin has an entry in the Base Station's Sensor table. The base station stores the actual Arduino IO Pin number internally, and you assign an ID value (anything from 0-32767) to the Sensor. JMRI references the Sensor using the ID value, not the Arduino pin number.

Sensor ID values do not need to be sequential. Each Sensor's ID can be any unused value within the allowed range (0-32767).

When using analog Arduino pins as digital inputs, use the pin's digital pin number. For example, analog pin A0 is digital pin 14

To control an Arduino IO pin using Indexed control, follow these steps.

1: Choose a System Name and a User Name

The Hardware Address for an Indexed Sensor is the ID value assigned in the Base Station's internal Sensor table. For example, if your sensor is connected to Arduino pin 7, and that sensor is assigned ID value 13 in the Base Station, the Hardware Address for that sensor should be 13.

The User Name can be anything you like.

2: Add the Sensor to the JMRI Turnout Table

NOTE: Sensor configurations stored in the Base Station's EEPROM will be automatically added to the JMRI Sensor Table on startup.

In the JMRI Sensor Table...

  1. Click the "Add" button
  2. Make sure "DCC++" is selected in the System Name chooser
  3. Enter the sensor's ID value in the Hardware Address box
  4. Enter the sensor's User Name in the User Name box
  5. Click "OK"
  6. Optionally click "Edit" on the new sensor's row and edit the sensor's configuration within JMRI
Entry Meaning makes System Name Mask Equivalent Minimum Maximum
4:3 (converts to 50) DS50 node : pin 0

3: Configure the Base Station

Use the JMRI/DCC++ "Configure Base Station" (4.6.x: "Configure Sensors & Turnouts") tool to store the Sensor ID and Arduino pin number in the Base Station.

  1. From the DCC++ Menu, choose "Configure Base Station" (or "Configure Sensors & Turnouts")
  2. Choose the "Sensors" tab
  3. Click the "Add Sensor" button. This will add a new row to the table.
  4. In the new row, set the "Index" to the ID value of the new output
  5. In the new row, set the "Pin #" to the Arduino pin number of the new sensor
  6. If the pin output needs the internal pullup resistor activated, click the "Pullup" checkbox.
  7. Click "Save Sensors" or "Close" and answer the prompts

Note: On JMRI versions 4.6.x and earlier, if you choose "Save Sensors" you will not be given the opportunity to write the changes to the Base Station's EEPROM. To write to EEPROM, you must choose "Close" instead of "Save Sensors".

General Notes

On Sensor IDs

Sensor IDs do not need to be sequential. You can use any unused value within the allowed range (0-32767). Sensor IDs can be the same as Turnout or Output IDs.

On Using the JMRI "Configure Base Station" Tool

The "Configure Base Station" tool is a convenient way to program the Sensor, Turnout and Output tables in your Base Station. It is not, however, required to work with DCC++ within JMRI. You can, for example, set up your Base Station's tables using the DCC++ serial command interface, or the DCC++ Controller software. As long as the IDs assigned in the Base Station match the Hardware Address assigned in JMRI's Sensor Table, all will be well.