Use infrared light sensors and a RaspberryPi to calculate train speed on a model railway.
- 2x IR break beam sensors
- 1x RaspberryPi (any type with GPIO)
IR break beam sensors are placed a known distance apart on either side of the track. With the Python script running any train passing along the track will break the IR beams which start and stop a timer. Using the measured time and known distance between sensors the scale speed in mph can be calculated.
The code assumes GPI 17 and 18 are used for the sensors and that they are 24 inches apart. Different distances and GPI pins can be used by simply modifying the code.