Hi! I'm working on a project which measures the speed of an indoor fitness bicycle and for that it needs to detect each time the pedal passes in front of a sensor. So far I've tried using a basic ultrasound sensor to detect each pass, but it seems very noisy and the speed isn't determined very accurately. Would an infrared sensor do a better job or is it just as noisy?
Also, for the pedal detection I calculate the difference between two consecutive measurements of the ultrasound sensor and if it is larger than a certain number then the detection is counted. Is this a good solution? If so, is there a way to reduce the noise from the sensor in order to calculate a more accurate speed? Thank you!
This all sounds like you having been trying to reinvent the wheel and getting a square one. You can get a proper bike speedo for as little as $3 - batteries included. Why not start there? At least you can be sure the sensor will work, and you might even get value from the rest of the bits. Other people do. I understood that they all use Hall effect but maybe they indeed do use a reed switch as alto777 suggests. Neither Infra red nor optical could possibly be a good idea, and I submit that using ultrasound doesn't even bear thinking about.
For my ultrasonic sensor I take 9 readings, sort them and use the middle one. However I don't know what your target looks like so this may not work in your case.
If I were to make such a system I would go the magnetic route. Its not bothered by ambient light nor dirt. Small neodymium magnets and reed switches are readily available.
You could also use a hall effect device like this one on Amazon. instead of the reed switch.