Рет қаралды 58,188
A step by step guide to adding sensors to your layout using an Arduino and JMRI. Adding sensors is the first step in automation and can be used to control trains, signals and points.
Part 1 - we build the sensor hub and connect an infrared (IR) sensor. This can be used to provide feedback from analogue or digital layouts.
Part 2 - we use two IR sensors to automate a train controlled by JMRI on a digital layout.
• Model Railway Sensors ...
Geoff Bunza's blog for the code and documentation:
model-railroad-hobbyist.com/n...
##### IMPORTANT INFORMATION #####
A few people have pointed out that the link to the files (script and sketch) on Geoff Bunza's website no longer works. I have uploaded these files to my GitHub area (github.com/LittleWicketRailwa..., but all credit should still go to Geoff Bunza for developing this system.
This is a simple way of adding sensor to a layout, but I would encourage anyone interested in this to explore the CMRI video series which uses the same hardware, but allows use of different sensor names, doesn't require a script to be run in JMRI and can be adapted to change inputs to outputs.
CMRI Part 1 - • Arduino, CMRI and JMRI...
CMRI Part 2 - • Arduino, CMRI and JMRI...
CMRI Part 3 - • Arduino, CMRI and JRMI...
########################################
The code you need to drop into the script to allow inverted sensors:
if sensor_state == 1 :
if s.getInverted() :
s.setKnownState(INACTIVE)
else :
s.setKnownState(ACTIVE)
if sensor_state == 0 :
if s.getInverted() :
s.setKnownState(ACTIVE)
else :
s.setKnownState(INACTIVE)
########################################
Ebay and Amazon Affiliate Links
(Full disclosure, as an Amazon Associate and Ebay partner I earn from qualifying purchases through these links and this helps to support the channel)
Arduino Mega:
amzn.to/3poEBQK
ebay.us/Zl3sDT
Mega Sensor Shield:
amzn.to/3rTq80V
ebay.us/M2VnYX
Variable Voltage Power Supply:
amzn.to/3b4wtj9
IR Sensors:
amzn.to/2LQJmVF
ebay.us/rnR5wn
26AWG Servo Cable:
amzn.to/3daEp55
ebay.us/L1q3FE
Crimping Tool:
amzn.to/3tRJXHE
ebay.us/XE2Dxl
Servo Wires (male to male):
amzn.to/3alIrFS
ebay.us/HfgTaO
Wire:
amzn.to/3dgxY0q
Chapters
00:07 - Introduction
01:00 - Tools & Equipment
04:26 - Steps
05:08 - Step 1 - Install Arduino software
06:23 - Step 2 - Connect Arduino to computer
06:44 - Step 3 - Download sensor sketch
07:28 - Step 4 - Upload sketch to Arudino
08:43 - Step 5 - Connect sensor shield
11:29 - Step 6 - Connect power supply (optional)
14:15 - Step 7 - Connect sensors
18:50 - Step 8 - Install JMRI software
19:53 - Step 9 - Create sensors in JMRI
22:11 - Step 10 - Download and run JMRI script