DIY Cycle Speedometer




About: I am a student studying engineering. Although I study mechanical engineering, I equally love electronics and electricity. I hope to post a few more of my projects and would be happy to help if you get stuck.

This project came to my mind when doing my MEM (Mechanical Engineering Measurement) project, a subject in my The idea is to measure the angular velocity of my bicycle's wheel. Thus knowing the diameter and the all time mathematical legend the pi(3.14) the speed can be calculated. Also knowing the number of time the wheel has rotated, the distance traveled can be easily known. As an added bonus, I decided to add a beaklight to my cycle. Now the challenge was to when to turn the brake light. Answer is below.

Step 1: The Structures

It is very important for this project to have a strong and stable supports. The thought is that the cycle may suffer a heavy impulse when it faces a pot hole or when you decide to have fun and take the cycle on a rough ride. Also, our input is captured when a magnet on the wheel crosses the hall effect sensor on the support. If all things go wrong simultaneously, the arduino will show speeds of a high speed rail. Also you don't want your best friend arduino to fall on road just because you decided to be lazy and use some cheap material

So, to be safe, I decided to go with aluminum strips as they can be easily be cut and drilled, corrosion proof and cheap which is always good for DIYing.

I also used some nuts (with washers) and bolts to fasten them on the frame as they must be securely placed on the chassis. Also this would help if you place the things wrong and have to relocate them.

Another important part is that the electronics must be properly isolated from the supports if they are made of any metal like I have made. The hot glue I used worked out just fine as it also absorbs some shock and cushions the display.

Step 2: Sensor and the Magnet

The measurement and input part of the project relies on this part.The idea is to place a magnet on the cycle wheel and add a hall effect sensor onto the frame so that every time the magnet crosses the sensor, the arduino knows a revolution is completed and it can calculate the speed and the distance.

The sensor used here is the classic A3144 hall effect sensor. This sensor pulls its output low when a particular pole faces the correct orientation. The orientation is very important as the outer pole will not effect the output.

Here are some pictures showing the proper orientation. Also the hall effect sensor requires a 10k pullup resistor. This in my project is substituted with the 20k pull-up resistors in the arduino.

Placing the magnet carefully is important. Placing it a little to far can result in inconsistent reading or missing revolutions and placing it very close may result in the magnet touching the sensor which is not very desirable.

If you observe carefully, the wheel will be having some tilt with the axis and this will result in crusts and troughs. Try placing the magnet in trough. I personally did not take so much efforts.

Step 3: Display

This display is theoretically optional but you need something to display the speed and the distance and sped in real time. Thinking about using a laptop is totally absurd. The display I used is a 0.96 inch OLED display with I2C as teh communication protocol between the slave and the master.

The pictures posted show the three modes the arduino automatically switches between.

1)The one with a small start in the lower left corner is when the arduino has just started and has successfully booted.

2) The one with km/hr is the speed. This mode is only displayed when the cycle is in motion and automatically goes off once the cycle stops.

3) The last one with meters (Long live the metric system) as units is obviously the distance the cycle has traveled. Once the cycle stops the arudino switches to display the distance within 3 seconds

This system is not perfect. It momentarily displays the distance traveled even when the cycle is in motion. Although this shows an imperfection, I find this one cute.

Step 4: Power Source

The project being a bit bulky, cannot always have a nearby wall outlet available for charging. So I decided to be lazy and simply use a power bank as a power source and use a mini usb cable to connect the usb power of the power bank to the arduino nano.

But you need to select the powerbank carefully. It is important to have a proper geometry so that it can easily be fitted. I am simply in love with the power bank I used for such a regular and square geometry.

Also the power bank must be a bit dumb. The thing is in order to save power, the power banks are designed to turn off the output if the current draw is not above a certain threshold value. I suspect this threshold to be 200-300 mA at least. Our circuit will have a maximum current draw of not more than 20mA. So, a normal power bank will shut down the output. This may lead you to believe that there is some fault an your circuit. This particular power bank works with such small current draw and this gave me another reason to love this power bank.

Step 5: Brakelight (completely Optional)

Just as an additional feature, I decided to add a brake light. The question was how would I find if I was breaking. Well it turns out that if I brake the cycle decelerates. This mean that if I calculate the acceleration and if it turns out negative, I can turn on the brake lights. This however means that the lights would turn on even if I just stop pedaling.

I also did not add a transistor to my light which is totally recommended. If some one does this project and properly integrates this part I would be more than happy to see that and add pictures for that.

I directly sourced the current from the digital pin 2 of the arduino nano

Step 6: The Program

As always I wrote the program on Arduino IDE. I initially aimed at logging the parameters onto a sd card. But unfortunately in that case I would have to use three libraries, SD.h, Wire.h and SPI.h. These combined with teh core occupied 84% of the available memory and IDE warned me of the stability issues. However it not too long that the poor nano crashed every time and everything froze after a while. Rebooting resulted in repeating the history.

So I scrapped the SD part and commented the lines which were related to the SD card. If someone was able to overcome this problem, I would like to see the changes.

Also, I've attached another pdf document in this step in which I have explained the code in detail.

Feel free to ask questions if any.

Happy DIYing ;-)



    • Organization Contest

      Organization Contest
    • Build a Tool Contest

      Build a Tool Contest
    • Trash to Treasure

      Trash to Treasure

    3 Discussions


    Reply 14 days ago

    Sure mate, here you go..
    Sorry for not including this in the original post.