Introduction: DIY Bike Tachometer
I will show you how to build a bike speedometer. It shows your speed,
the average speed,the temperature, the trip time and the total distance. You can change it using the button. Additionally, the speed is shown on a tachometer. I built it because I like building new things, I have not found anything like this on the internet so I want to show you how to build a good speedometer as the one on my bike is not as cool as I want :) . So let's get started.
Step 1: Parts:
This is a list of parts that you will need. They costed me about $ 40:
- Arduino
- Bike with reed switch
- LCD display 16x2
- Servo
- Breadboard
- Thermometer DS18B20
- Resistor 1.2k Ω , 4.7k Ω
- Switch
- Button
- Potentiometer 10 kΩ
- 9V battery
- Cables
- Box
- Tools (drill, soldering, knife, tape)
Step 2: Connection
I added a picture from Fritzing and verbal description of how to connect it. In the picture all red wires are connected to 5V, all blue cables are connected to GND.
- LCD display:
VSS --> GND Arduino
VDP --> 5V Arduino
VO --> output potentiometer (potentiometer VCC -> 5V Arduino, potentiometer GND -> Arduino GND).
RS --> pin 12 Arduino
RW --> GND Arduino
E --> pin 11 Arduino
D4 --> pin 5 Arduino
D5 --> pin 4 Arduino
D6 --> pin 3 Arduino
D7 --> pin 2 Arduino
A --> 5V Arduino
K --> GND Arduino
- Servo:
VCC --> 5V Arduino
mass --> GND Arduino
Data --> pin 6 Arduino
- Thermometer:
VCC --> 5V Arduino
mass --> GND Arduino
Data --> pin 1 Arduino
data and power is connected via a 4.7 kΩresistor
- Sensor on wheel:
one end -> 5V Arduino
second end -> A0 Arduino and resistor 1,2 kΩ
The other end of the resistor to ground in the Arduino
- Button:
one end --> 5V Arduino
second end --> A1 Arduino
Step 3: Upload Code:
Below I added the code in comments there is an explanation.
links to the download libraries:
http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip
https://github.com/milesburton/Arduino-Temperature-Control-Library
If you have a different wheel diameter you have to change it. You can calculate it with this formula:
circuit = π*d*2,54 (d=diameter of your wheel, I multiplied it by 2.54 to get the result in meters).
/* ################################################## Copyright by Nikodem Bartnik june 2014 ################################################## */ //librarys #include < Servo.h> #include <LiquidCrystal.h> #include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 1 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); //LCD display pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //servo name Servo myservo; //definition of variables long previous, triptime, time, impulses; float speedometer, dist, aspeed; int servo; int screen=1; //If you have other circuit of wheel you need change it float circuit=2.0; double temperature; void setup() { lcd.begin(16, 2);</p><p> pinMode(A0, INPUT); pinMode(A1, INPUT); //servo definition and setting the tachometer to 0 myservo.attach(6); myservo.write(180); lcd.print("Bike tachometer"); delay(1000); lcd.setCursor(5, 1); lcd.print("V 1.0"); delay(4000); lcd.clear(); delay(500); lcd.setCursor(0, 0); lcd.print("Dist:"); } void loop() { //if wheel turns if(analogRead(A0)>=300){ //number of turns++ impulses++; //count turn time time=(millis()-previous); //count speed speedometer=(circuit / time)*3600.0; previous=millis(); Tachometer(); delay(100); } Lcd(); } //display speed on tachometer void Tachometer(){ //map speed 0-180 to servo speedometer=int(speedometer); servo = map(speedometer, 0, 72, 180, 0); //setup servo myservo.write(servo); } void Lcd(){ //when button is clicked if(analogRead(A1)>=1010){ lcd.clear(); screen++; if(screen==5){ screen=1; } } if(screen==1){ //displays speed lcd.setCursor(0, 1); lcd.print("Speed:"); lcd.setCursor(7, 1); lcd.print(speedometer); lcd.print("km/h"); } if(screen==2){ //displays themperature temperature=sensors.getTempCByIndex(0); sensors.requestTemperatures(); lcd.setCursor(0, 1); lcd.print("Temp:"); lcd.setCursor(7, 1); lcd.print(temperature); lcd.print(" C"); } if(screen==3){ //displays averagr speed aspeed=dist/(millis()/1000.0)*3600.0; lcd.setCursor(0, 1); lcd.print("A.speed:"); lcd.setCursor(8, 1); lcd.print(aspeed); lcd.print("km/h"); } if(screen== 4){ //diplays trip time triptime=millis()/60000; lcd.setCursor(0, 1); lcd.print("Time:"); lcd.setCursor(7, 1); lcd.print(triptime); } lcd.setCursor(0, 0); lcd.print("Dist:"); //calculation of the distance dist=impulses*circuit/1000.00; //dislays distance lcd.setCursor(6,0); lcd.print(dist); lcd.print("km"); }
Attachments
Step 4: Pack
As a cover I used a plastic box I bought for $ 1. I cut holes using a knife and a drill. Servo and LCD display I glued with a tape, tip I made with carton and painted it with paint. I did shield in Corel Draw X5 and I printed it, I added a PNG image, and Corel Draw file (if you want, you can edit it). I clipped the box to steering wheel on my bike and I soldered cables to the reed switch.
Attachments
Step 5: Run It!
Now it is ready. All you need to do is turn it on and ride. Have fun with your speedometer. If you like this project, please vote on me.

Participated in the
Battery Powered Contest

Participated in the
Wheels Contest
26 Comments
5 years ago
Nice prototype-grade project, not yet practical, but it can be developed a bit. I was thinking about something like that, running on hub dynamo power (maybe even using its frequency as the tachometer/odometer input signal?), using Arduino Pro Mini and a Nokia 3310 display. No analog meters though, as they aren't too shock-resistant (unless you use military grade).
9 years ago on Introduction
what are you using for the sensor
Reply 9 years ago on Introduction
I use reed switch.
Reply 6 years ago
What are you using to close the reed switch? Usually a magnet is used. Did you leave this out or is there another way to activate the switch?
6 years ago
What is the maximum speed? Can I use it in a car?
Reply 6 years ago
Yes, you can use it in a car
Reply 6 years ago
I intend to use only the LCD
8 years ago on Introduction
i have run the code, but it counts by it self and the speed is 63 as a stable speed. It should give 0.00 . Any solution for that?
and thank you for the ide
Reply 6 years ago
Congratulations Nikus, great proyect, but I have the same problem. Can you help me? Mi email is vordesigns@hotmail.com. I will thank you very much.
Reply 6 years ago
Check if you have everything alright with connection. Hard to say but for sure you have problem with hardware. It is also possible that you used NC reed switch (normally close) but you should use NO (normally open)
Reply 6 years ago
hi, is very important this proyect for me, can you sell me the proyect Assembled and working? i really apreciate a good price.
Reply 6 years ago
I really appreciate your response. I checked the connections and they are well, I even put the cables of the same color that your own but still the same. My switch is a push buttom (NO). I'm thinking that the problem may be the libraries that may change or be different from yours. Could you send them to my mail? vordesigns@hotmail.com. Thanks very much Nikus!
Reply 7 years ago
I have the same problem.
7 years ago
This is a speedometer ,not a tachometer.
7 years ago
Which arduino board you have used?
Reply 7 years ago
leonardo
7 years ago
Looks really cool! I can put this on my To-Do list (after I learn arduino :( ...)
Reply 7 years ago
Thanks! Good luck with arduino
8 years ago on Introduction
Could you tell us more about Reed switches and How to connect Reed switch to wheels..?
9 years ago
is there anychance that the sensor would be a steppermotor connected to the wheel ?