Sensing the Sensors

The track's going to end up with tens and tens of sensors, so it's going to need a reliable way to detect those sensors and report back to the main software.  The network grid of 'Espduinos' that talk to the central control software are great, but they only have a very small number of digital pins, making them useless for sensors.

My chosen method is to use a Arduino Mega and a Screw Shield board.  The mega will connect via Serial to the Espduino, and the Espduino will relay any events back to the control software.

Here's an Arduino Mega - actually technically it's a cheap chinese knock-off version.  Costs about £10 from Ebay.
And here's the screw shield, costing about £25.  It gives an easy way to connect cables to it.

At first I simply hooked the cables up to the digital ports, and it mostly worked - BUT - i was getting a lot of spurious misfires of the sensors.  It was quite common for a sensor to fire, and for pins very close to it to fire as well.  Not good.  I fixed it with two separate approaches:

Fix 1 - More powerful Pull-up Resistors.  Each pin had a 1k resistor soldered between it and 5v.  This was done in the 'prototype board' section of the screw shield.
Fix 2 - Shielded cable.  For the longer runs, the shielded cable fixed the problem. DCC signal is very 'dirty' and gives off a lot of noise, enough to trigger the sensitive Arduino's digital pins.

Comments