Introduction: DIY SPEEDOMETER AND ODOMETER

Hey guys, this a instructable of how to make a bike speedometer.Yeah,you read it right the one that we use in car but only for 10$ .Well the first this for you to know is that this is the collaborated project of Mr_DIY_Electrician and paurushthemaker .So back to topic our project is all about a speedometer which has 3 modes as follow:-

Speedometer(for speed) and odometer(for distance)

Task1.-Cover 20 miles

Task2-Achieve 30mph speed

And yes one more thing is that this is a arduino speedometer so there is no limitation for imagination. Let's Get Started.........

Step 1: HOW IT WORKS

The working of a project is simple. It is also very important to understand it for making the project. Basically the apparatus consists of the reed switch or the magnetic switch mounted on the frame of the cycle and a magnet mounted on the one of the spokes. As the wheel rotates the magnet triggers the switch every rotation. The signal go to the arduino which counts the no of rotation and finds the distance covered(you have to pre enter the diameter of your cycle). The arduino also measures the time and calculates the speed. The output from the arduino then goes to the lcd where it is shown in miles per hour (you can convert it if you want).

Step 2: MATERIALS REQUIRED

The full project would cost you about 5$-10$ depending on the place you live in. The cycle speedometer also would require moderate soldering skills and an afternoon. so without any further ado the materials for the build are --:

1. The arduino board - i got Rs.330 which is around 5$ but to programme the pro mini you will also need to have an arduino uno or an usb to ttl adapter (how to program an arduino pro mini with an uno) or if you don't have it then use an arduino micro or an arduino uno.

2.Arduino 16x2 lcd (Rs150 or 2.3 $)

3.7805 voltage regulator (increases the control over the contrast no major difference -optional)

4. 2x switches for backlight and on off (optional)

5.220 ohm resistor

6. trimer pot 10k ohm

7.female headers and male headers if you want the reed switch to be detachable

8. reed switch

9.wire

10. a momentary switch to change the modes

11. 0.1uf capacitor to reduce the debounce of the button

12.10k ohm resistor

The tools you would require are

1. soldering iron

2.solder

3. enclosure

4. cutting tool like the dremel to cut out holes in the enclosure to mount he lcd and stuff

5. hot glue or any adhesive to mount the various components.

Step 3: THE CODE

Before moving on to the electronics it would be good to flash the code so that you don't need to struggle between wires afterwards

flash the given code on the arduino but DON'T FORGET TO SET IN THE DIAMETER OF YOUR CYCLE.

the code can be downloaded below

Step 4: THE ELECTRONICS

The wiring diagram can be found above also I have mentioned it down

LCD -ARDUINO

1 - GND

2 VCC

3 VIPER PIN OF THE POT (ends to vcc and gnd and center to pin 3 of lcd)

4 13

5 gnd

6 12

7 --

8 --

9 --

10 --

11 11

12 10

13 9

14 8

15 VCC

16 GND

Also

a 220 ohm resistor is to be connected between pin 2 of the arduino and ground(pull down)

the momentary switch is connected to pin two and vcc

a 0.1 uf capacitor between the two terminals of the switch to reduce the debounce

the reed switch to vcc and A0

a resistor between A0 and gnd (pull down)

After connecting all this the wiring would be complete and now you can connect power and check if every thing is working

Step 5: THE ENCLOSURE

The enclosure can be a plastic box or a wooden , just that it should be sturdy and should have enough space.

After mounting the switches ,lcd,button and headers do check the working of the device also.

as far as possible try and make it waterproof because the cycle goes into the worst of the conditions.t

Step 6: TESTING AND TROUBLESHOOTING

Connect a 9v battery and test all three modes completely. Bring a magnet close to the reed switch and the speed and distance should increase.

If it is not so in your case then post your doubts and queries in the comments and i will answer them back as soon as possible...

Comments

author
ok121 made it! (author)2015-11-17

Hey guys,

I copied and pasted the speedometer code onto my arduino, but get either binary results: it read either 0.0 mph or 47 mph. When it read 47pm, there was a long delay in the reading before the "speed" went back down to 0 mph.

I installed simpler code just to test out the reed switch and it is reading the magnetic field correctly, so the issue isn't in the reed switch. I wonder if there's an issue with the code or the arduino setup.

Have any of you guys also faced this similar issue? If so, how did you resolve?

Thanks,

John

author
Md_1704 made it! (author)Md_17042017-03-22

i am facing similar kind of problem. The code does display intermediate values at lower rotational speed but at higher rotational speed it displays 47 mph constantly irrespective of the speed of the rotation.

author
David10153 made it! (author)2017-02-14

what Arduino did I you buy?

author
CornelN1 made it! (author)2016-04-10

Hello,

i am workind on something similar, he differences are:

- i have a line follower sensor on digital pin 2

- i have a black and white stripe with 20 mm between 2 white stripes

- i need the output on the serial monitor, and not on the lcd.

i have put up a sketch, but i have some issues with the time.

i need to:

- start the counting every time the pin 2 changes (the sensor has moved) and count the millis until next pin 2 changes, and have the speed. at the end, if the pin 2 does not changes for 1 sec, the program stop's

can someone help me?

i have this sketch until now:

// Constante:

const int buttonPin = 2; // pinul digital pentru senzorul de linie

// Variabile:

int buttonPushCounter = 0; // counter numar impulsuri (1 sau 0)

int buttonState = 0; // starea actuala a senzorului de linie (1 sau zero)

int lastButtonState = 0; // starea anterioara a senzorului de linie (1 sau zero)

long time = 0;

void setup() {

// inititalizeaza intrarea pentru senzorul de linie:

pinMode(buttonPin, INPUT);

// initializeaza comunicatia seriala:

Serial.begin(115200);

Serial.println("________________________");

Serial.println("Program test");

Serial.println("________________________");

}

void loop() {

// citeste intrarea senzorului de linie:

buttonState = digitalRead(buttonPin);

time = 0;

// compara starea butonului actuala cu cea anterioara

if (buttonState != lastButtonState) {

// if the state has changed, increment the counter

if (buttonState == HIGH) {

// if the current state is HIGH then the button

// wend from off to on:

buttonPushCounter++;

time++;

}

Serial.print("Deplasare [mm]: ");

Serial.println(buttonPushCounter*20);

Serial.print("Timp [s]: ");

time = millis();

//prints time since program started

Serial.println(time/1000);

Serial.print("Viteza [mm/s]: ");

Serial.println((buttonPushCounter*20)/(time/1000));

Serial.println("________________________");

// Delay a little bit to avoid bouncing

delay(1);

}

// save the current state as the last state,

//for next time through the loop

lastButtonState = buttonState;

time = 0;

}

author
JOANAHR made it! (author)2016-03-30

Hey guys, does anyone know what he meant by pin 2 for the momentary switch? is it from the LCD or pin 2 from Arduino?

author
CălimanuL made it! (author)2016-03-16

hello i want to build an arduino that measures speed and a proximity sensor , something like i can set it in the car near to see how fast i am going , also i want to make a sensor that will tell me the distance between my hand and my sensor.

what would i need to do that?

author
BartoszH1 made it! (author)2016-03-10

how to make it in km/h ?

author
henrypulford made it! (author)2015-09-07

Hi there thanks for the great instructable! I just wanted to know if it would be possible to add a startup message into the code so when the divice is first powered on it would say "Henrys Bike" for like 10 seconds - Thanks :-)

author

In the beginning of the setup section on the code, put something like:
lcd.print ("");
delay (10000);
lcd.clear ();


The rest of the code goes below.

author

In the quotations is where your message will go

author
ztaticz made it! (author)2016-01-15

Can anyone explain the purpose of the reedcounter and max reed counter?

author
ok121 made it! (author)2015-11-17

Hey guys,

I copied and pasted the speedometer code onto my arduino, but get either binary results: it read either 0.0 mph or 47 mph. When it read 47pm, there was a long delay in the reading before the "speed" went back down to 0 mph.

I installed simpler code just to test out the reed switch and it is reading the magnetic field correctly, so the issue isn't in the reed switch. I wonder if there's an issue with the code or the arduino setup.

Have any of you guys also faced this similar issue? If so, how did you resolve?

Thanks,

John

author
npitz made it! (author)2015-10-19

how to convert from MPH to KMH?

what the meaning of value = 56.8 on equation below:

"mph = (56.8*float(circumference))/float(timer);//calculate miles per hour"

would you explain to me about "how it work" of your code?

author
tiger12506 made it! (author)tiger125062015-11-09

I'm not the OP, but this is how:
you provide r [in]

1000 [cyc] * 60 [sec] * 60 [min] * [ft] * [mi]
---------------------------------------------
12 [in] * 5280 [ft] * [sec] * [hr]

= 56.81818...

The 56.8 is just unit conversion from (circumference in inches per 1000Hz interrupt) to (miles per hr)

To get kilometers per hour, just do one more unit conversion

mi 1 km
----- * --------
hr 0.621371

In other words, change 56.8 in the code to 91.44 (still specifying radius in inches)
(you'll have to change other magic values in the code too)

To do it properly (specify radius in cm) you should redo the calculation similar to what I have done above, but starting from centimeters instead of inches. Left as an exercise to the reader.

Here's the fancy name for what I've done in a wikipedia article.

https://en.wikipedia.org/wiki/Dimensional_analysis


in school we called it the "factor label method"

author
DeanG2 made it! (author)2015-08-20

This is now housed in a plastic 3x5 card box, temporarily stuck to the bike with a couple of "repair straps" of metal from the big box store. This means my wife can know clock her workouts. I just have to repair the cracked vinyl seat and the front roller that cracked of the axle.

author
DeanG2 made it! (author)2015-08-19

I had an exercise bike without a control head. It died years ago. The back bar under the seat is extra long so I sometimes trip over it. I was going to junk the thing until I found this article. The project is running, but is not in a housing yet. I'll post pictures of the unit and the installation. Thanks for saving us a TON on exercise equipment.

author
PaurushTheMaker made it! (author)PaurushTheMaker2015-08-19

congratulations
and thanks for the encouraging comments

author
erik_montesdeoca made it! (author)2015-07-16

Great Job ¿Do you know how to convert to energia code for msp430g launchpad o TI?

author
mholthaus99 made it! (author)2015-06-12

Hey electroguyz,

I have tried your code and many others on Instructables. I am not using an LCD currently with this project, just the Serial Monitor. When the switch is high, the Serial Monitor will display the speed and then "47.68 mph" after that, until the switch is closed again. Unlike the other sketches, the Serial Monitor will display the speed for at least one line. There seems to be quite of few people having problems with this on other instructable, yet no answer. Any suggestions? Thanks.

On some of the other sketches, I eliminated the LCD factors within the code and was still getting the same result.

author
phelps_br made it! (author)2015-05-25

hi my congratulations on your project, I am willing to use my old moped 1978, more wanted to convert to KPH, I'm starting now with Arduino and do not know how to make this change from mph to kph. thank's for your time.

author
dumbau made it! (author)2015-05-04

Just wondering if a Hall Effect speed sensor would be more reliable than the reed switch? I think that the reed switch has a moving part that seems like could be affected by bumps. I also wonder if it would work above a certain speed?

author
electroguyz made it! (author)electroguyz2015-05-04

no a hall effect sensor will not work that well because a hall effect sensor also measures proximity of a magnet also. This will cause multiple readings and false triggering

though you can use a hall effect switch

author
dumbau made it! (author)dumbau2015-05-07

Thanks for the response. I am new to the Arduino and electronics in general so thanks for indulging my newbie questions. If I understand your code, it appears that you are using an interrupt to check the reed switch 16 times a second (correct?). Every time that it detects that the switch is closed, it sets the counter to zero. This would have the effect of eliminating multiple reads in case the switch is still closed on subsequent interrupts. Once the switch is open, the number of 1/16th second intervals are counted until the switch closes again and the speed is calculated (using circumference and number of timer intervals). It would seem that a hall effect sensor would behave in exactly the same way as the reed switch because your interrupt logic discards multiple readings. Maybe the difference has more to do with the the type of signal that hall effect sensor provides or maybe that is the difference between a hall effect sensor or switch that you alluded to? It turns out that I have a hall effect sensor in my Arduino starter kit. It gives me a high or low reading but nothing in between. Do you think this means that it is a hall effect switch?

author
electroguyz made it! (author)electroguyz2015-05-05

See the thing is that use hall effect sensor will give more precise and accurate result.But DIY means making things cheaper and other thing is that it would take more space to program it.

author
electroguyz made it! (author)electroguyz2015-05-05

See the thing is that use hall effect sensor will give more precise and accurate result.But DIY means making things cheaper and other thing is that it would take more space to program it.

author
electroguyz made it! (author)electroguyz2015-05-05

See the thing is that use hall effect sensor will give more precise and accurate result.But DIY means making things cheaper and other thing is that it would take more space to program it.

author
electroguyz made it! (author)2015-05-03

Please support us like this and feel free to ask any doubts

author
jsullivan27 made it! (author)2015-05-03

Great idea!!

Didn't see the wiring diagram though....?

author
electroguyz made it! (author)electroguyz2015-05-03

thanks
I gave mentioned the wording diagram for the LCD but for the switches and resistors I have just written it down

author
electroguyz made it! (author)electroguyz2015-05-03

wiring

sorry because of the autocorrect

author
seamster made it! (author)2015-05-03

This is a really cool idea! Nice work!

author
electroguyz made it! (author)electroguyz2015-05-03

thanks

About This Instructable

57,883views

186favorites

License:

Bio: We are two electronic hobbyist aiming to unleash the capability of arduino
More by electroguyz:DIY SPEEDOMETER AND ODOMETER
Add instructable to: