Smartphone HTML control for model trains, using ESP32 microcontroller, WiFi access point, asynchronous webserver, WebSocket and JSON, outdoor compatible with on-board USB power supply
optical reading is easily possible with a digital or analog input of ESP32
black sleepers are equally spaced on model railrod track
check whether ambient light is good enough to pick the contrast between black sleepers and in between lighter material. alternatively, a light barrier element with an active light source can be used
the reflective light optical pulses converted to an electrical signal can be converted to a frequency of passing sleepers and a true speed over ground measurement
define GPIO pin 26 as input for monitoring motor current on a 1 Ohm resistor between ground and motor IC grounding,
display and moinitor its voltage of approximatly up to 1 V, which is proportional to motor current as number on control panel
and its change over time recorded in a buffer and displayed in an extra website, which also allows for speed adjustments,
so that their effect can be monitored online. Let me know if you like to go for it together.