Bike speed with Arduino and speedometer hallotron sensor.

For my recent project I needed a way to read speed of revolving circle. I found but I wrote my own code that works slightly different.

I bought the cheapest bike speedometer (for around 3$), cut the sensor and attached it to analog pin 0. The idea is to wait for the magnet to pass hallotron (HIGH/LOW state change), than wait for LOW/HIGH state change and measure the time difference.

In my case I noticed that hallotron may go HIGH/LOW/HIGH when the magnet is passing (there were some 15ms gaps) – this situation is not what we want to measure and I excluded it with HYSTERESIS constant.

My code uses Timer One library available here: I recommend using it, it works. The guide how to install Arduino libraries is here.

I used SI units, some variables and constants will need adjustments for your projects.

Here is the code:


Leave a Reply

Your email address will not be published. Required fields are marked *