One of the things that came up time and time again at my model railway club was the topic of driving our exhibition layout at scale speed. Different people had different ideas of what speed things moved at. I decided it would be fun to have something to measure the speed.
At the same time I was playing with a little WiFi processor, the ESP-01. It was supported by the Arduino development environment, was small enough to fit into a wagon and had a few inputs. I couldn't resist the challenge.
I decided to use something called an interruptor sensor, basically a light source and a light detector in a fork arrangement. Pass an obstacle between them and you detect its presence.
I attached a strip of brass to a bearing that was then attached to the axle with loctite.
The brass would interrupt the light between the two forks of the sensor, which protruded through the floor of the wagon. I would get a signal every time the wheel performed one half revolution.
A power supply was added to give the 3.3 volts required from a little PP3 battery and the whole assembly fitted in a Parkside Mink G.
Now all that was needed was the software and a little maths. The wheel was an 11mm diameter and the simple equation told me that the distance travelled in one rotate was pi * d, e.g. 3.14 * 11 mm. All I needed to do was convert that to a scale value, for 4mm to the foot, count the time between 2 signal (half a rotation) and I could derive the speed.
There was already a library available that allowed the ESP-01 to be a WiFi hotspot, and to support a simple web server. From this I then put those bits of code to together such that any machine could attach to my Mink G's WiFi and use a web browser to get the speed of the wagon.