Introduction: DIY Cycle Speedometer
This project came to my mind when doing my MEM (Mechanical Engineering Measurement) project, a subject in my B.tech. 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 ;-)
12 Comments
1 year ago
非常感谢!加速度刹车灯的设计非常好,很棒的项目!正是我需要的。
我重新改进了代码,增加了记录累计骑行距离和显示单次骑行时间。接下来,准备用3D打印外壳并将其组装到自行车上。
Reply 9 months ago
wow!
Thats fantastic. If you can send me the code, I will put it in this instructables
Reply 9 months ago
我可以要程序文件吗
2 years ago
first tested it with a push butten switch
debounce on switch makes wheelcount and thus km/h incorrect
so a reed sensor will not work i think
with a hall sensor it works perfect
https://github.com/ldijkman/arduino_bicycle_computer/blob/main/speed.ino
Reply 1 year ago
Hello,
Sorry for the late reply.
You're right. The switch will have some debounce issues. I guess you can solve it by using a RC filter and fine-tuning the time constant. However, a switch is susceptible to wear and tear but non contact type sensors are far more resistant to such wear.
Have a good day
Question 3 years ago on Introduction
Hi there HarshadB9. I'm a newbe to Arduino and I am attempting to build a set up to measure a model speed boat for a friend. I liked your instructable because of the large display (he is short sighted). Anyway. I've done the hardware. You might like to watch my 7 munute YT clip. I'm old school (70) and code writing is new to me. I'm an analogue guy who cut his teeth on valves! lol. I've set up a cloned Arduino Nano and a 1.3" Oled and uploaded the code. I haven't go the sensor wired in yet. I'm gonna have to build a little circuit to provide pulses rather than a square wave (as in the clip). Easy for me, but coding - er, no!
I only need the speedo function and nothing else. So I just need the display to provide MPH. My friend's boat achieves a real speed of 104 MPH and more.
There is more he'd like but I'll settle for the raw speed reading for now then sweat over that later.
I've taken a photo of the display after loading the code and it looks like this. So, I'm obviously doing something wrong! (Have Oled SSD1306 in library and using IC2 like yours.
https://drive.google.com/file/d/1XjrdunBBgrWZWq16RX1XHtYzJxq5V0Di/view
Thank you so much. BTW, keep safe!!
Eddie
Answer 2 years ago
Hi mate,
Sorry for being so so late. Don't know if my answer is required anymore.
The display might be a result of some mistake in wiring. First try the example codes in the arduino library and check if it works. If it works, get back to me.. I will help you rewrite the code.
Else check if the display is broken, i.e. try a new display or try changing the arduino.
In any case, let me know if it works. Happy to help. Take care
Question 4 years ago on Introduction
I'm looking into building a 7' touchscreen instrument cluster (speedo with the gauges) for my 2008 Honda CBR1000RR Fireblade, you wouldn't have any tips for me or could point me in the correct direction as to finding pertinent info?
Answer 4 years ago
You have a very nice and beautiful bike.
If I was at your place, I would not have tampered with the guages of bike.
Modern bikes don't work as simple as my project. You risk damaging your bike's mother board.
Anyways, if you try the project, I will be happy to see it's pictures.
All the best
Question 4 years ago on Step 1
would please share assembly/wiring
thanks
Reply 4 years ago
Sure mate, here you go..
Sorry for not including this in the original post.
Reply 4 years ago
Thanks