Bike speedometer for n900

GPS is good, but it's accuracy is not suitable for measuring bike speed. In this post I'll tell you how to make bike speedometer. It doesn't require any special skills and hardware, only basic soldering skills and soldering iron. This post describes only hardware part, because software is not ready yet, through it is definetely known, that it is not hard to write it. We will start from theory. We a going to measure rotation speed of wheel and calculate linear spead of a bike. All you have seen usual bike computers and a sensor with which is attached to a fork with a magnet, which is attached to a wheel. But I guess, that for most of us sensor was just a black box which did it's job. Actually, it is just a dry reed, which you can buy in a shop for about $1.5. Whan magnet passes near it, switch closes the circuit and current flows. Bike computer measures time intervals between impulses and calculates speed.
You also would need two resistors ($0.5 x 2) to make phone understand, that something is connected, wires, thrink tubes, insulating tape, magnet ($1.5), unneeded knitting needle and 4pin 3.5 jack. The latest is the most problematic, people say, that it is not possible to find it in a shop, so you would have to take one from headset (fortunately nokia gives a shitty headset with n900, which can be used as a donor).
Schematic is very simple, but firstly we have to understand how n900 detects headphones. Connector has four contacts, which are (starting from the wire) ground, microphone, right channel, left channel. We are interested in two first. If they are shorted, n900 thinks, that headphones are connected, because they have usual 3pin jack. If contacts are not connected (resistance is greater than 1.5 kΩ), then phone thinks, that nothing is connected. If there is a resistance about 1 kΩ n900 thinks, that headset is connected. That is what we need.
Next point is a button on a headset. It just shorts circuit throught resistor. Multimeter shows, that it is about 50 Ω, but I decided to have much bigger resistor so as not to overload sound tract (I didn't think about button at first and then it just worked, so I don't see a reason to change anything). I use 2kΩ resistor connected through leed in parallel with first resistor. So when leed is closed total resistance of the circuit is 1/3 kΩ.
And the last thing is how to read data from this sensor. There are two ways. Sound card records sound does not record sound, it records voltage, and as far as resistance of sensor changes, voltage on microphone input changes too (phone powers the input). Sound card has capacitor in it's circuit, which cutts of constant component of voltage, so instead of plateu you would see two implses: one positive when leed closes and another negative when it opens (see attached bike.wav I spinned the wheel two times and then it gradiently stopped). It is wery simple to check, that at current moment voltage is higer, than some value and it wasn't at previous moment. This method is very precise, but it is power consuming too (also, it should consume much less power, than mediaplayer when playing music).
Another way suggested by Flandry is to read /sys/devices/platform/nokia-av/detect which changes from 4 to 0, when leed is closed. It is not as precise, but should consume less power. Now several advices about assembling. Dry reed contacts must be perpendicularly to direction where magnet is located. This direction should lay in a plane in which contacts move. If reed is located as shown on photo, magnet should be above it. Othervice reed would not be sensitive anough. I used pieces of knitting needle to attache reed to fork. Firstly cover them with shrink-tube so as not to scratch fork. Then put reed between them and secure this construction in a wide shrink tube or by winding it with insulation tape. As far as resistor are very small you can just cover them with insulation tape, no need for special case. If done neatly connection would not be much wider, than wire and would look good. You can connect four left wires to minijack nest so as not to loose ability to attach headphones.
You can see additional photos in a gallery.
AttachmentSize
bike.wav12.65 MB

Comments

Very cool

I like that you're sending data using a 3.5mm cable. I made a bike dashboard for a Nokia Competiton and use a hall effect sensor transmitting the data from an arduino to the N900 over bluetooth. A little overkill, but it was a fun project and an awesome learning experience. Check it out!

http://www.submergedspaceman.com/blog/?p=57

Good luck with the project!
bjppolo@gmail.com

Accuracy

Have you measured the accuracy? Why do you say it's not good enough?

GPS can be very unstable,

GPS can be very unstable, especially in city when signal is blocked and reflected by trees and buildinds. I do map with OSM2GO and I know how far location detected by GPS can be from me. This error changes over time so GPS speed is a summ of your speed and and speed of changes of error. So it is several kmph higer, than your real speed. In a car this does not mean much, on a bike this could be half of your real speed.