I needed something that would act as a detector on a double slip, which is a comparatively short length of track and ended up looking at light dependent resistors (LDRs), also known as photoresistors, or photocell resistors.
The ESP32 LDR tutorial referenced in the video https://esp32io.com/tutorials/esp32-light-sensor
The LDR class and sample sketch used in the video https://github.com/Vintage80sModelRailway/LDRSensorMonitoring
I've created a repo for all of my current live node sketches across the Arduinos, ESP32s and Galileos. All of them are written in the Arduino IDE.
https://github.com/Vintage80sModelRailway/JMRI-Nodes
The LDRs I bought (no affiliate links) https://www.ebay.co.uk/itm/404362187416
#modelrailways #modeltrains