bicycle odometer Arduino Archives - Global Travel Noteshttps://dulichbaolocaz.com/tag/bicycle-odometer-arduino/Sharing real travel experiences worldwideThu, 26 Feb 2026 10:57:11 +0000en-UShourly1https://wordpress.org/?v=6.8.3Arduino + Geometry + Bicycle = Speedometerhttps://dulichbaolocaz.com/arduino-geometry-bicycle-speedometer/https://dulichbaolocaz.com/arduino-geometry-bicycle-speedometer/#respondThu, 26 Feb 2026 10:57:11 +0000https://dulichbaolocaz.com/?p=6569Turn your bicycle wheel into a math-powered speedometer with Arduino. Learn how to measure wheel circumference, choose a reed switch or hall effect sensor, wire it reliably, and calculate real-time speed and distance using simple geometry. This in-depth guide covers interrupts, debouncing, smoothing jittery readings, calibration methods, and practical mounting and waterproofing tipsplus real build lessons learnedso you can create a bike computer that’s accurate, durable, and genuinely fun to use.

The post Arduino + Geometry + Bicycle = Speedometer appeared first on Global Travel Notes.

]]>
.ap-toc{border:1px solid #e5e5e5;border-radius:8px;margin:14px 0;}.ap-toc summary{cursor:pointer;padding:12px;font-weight:700;list-style:none;}.ap-toc summary::-webkit-details-marker{display:none;}.ap-toc .ap-toc-body{padding:0 12px 12px 12px;}.ap-toc .ap-toc-toggle{font-weight:400;font-size:90%;opacity:.8;margin-left:6px;}.ap-toc .ap-toc-hide{display:none;}.ap-toc[open] .ap-toc-show{display:none;}.ap-toc[open] .ap-toc-hide{display:inline;}
Table of Contents >> Show >> Hide

If you’ve ever looked at a bicycle wheel and thought, “That’s basically a rotating math problem,” congratulations:
you’re exactly the kind of person who ends up building an Arduino bike speedometer.
The recipe is delightfully simple: count wheel rotations, multiply by wheel circumference (hello, π),
and divide by time. That’s it. Your bike becomes a rolling spreadsheetexcept it’s faster, louder, and occasionally
tries to shake screws loose.

In this guide, we’ll build the brain of a DIY bicycle speedometer (and odometer) using an Arduino and one small sensor,
then we’ll lean on geometry to turn raw wheel “clicks” into real speed. Along the way, you’ll get practical
mounting tips, accuracy tricks, and code logic that won’t melt down the moment you hit a pothole.

What You’re Building (and Why It’s Surprisingly Accurate)

A bike speedometer measures how fast your wheel spins. One full wheel rotation equals one wheel
circumference of travel. So if your tire circumference is 2.105 meters (a common road-bike value), every time your wheel
completes a revolution, you’ve traveled 2.105 meters. If you also know how long that revolution took, you can compute speed.

The Arduino’s job is to:

  • Detect each wheel rotation (with a magnet + sensor).
  • Measure time between rotations (using the Arduino’s clock).
  • Compute speed and optionally distance, average speed, max speed, and trip totals.
  • Display the results (LCD, OLED, LEDs, or even a phone via Bluetooth if you feel fancy).

The Geometry That Turns Spins into Speed

Step 1: Get Your Wheel Circumference (Without Guessing)

Geometry says circumference is C = π × D. Real life says tires squish, rims vary, and your “700c”
isn’t a magical universal constant. The most accurate method is the “rollout” measurement:

  1. Inflate your tire to your normal riding pressure.
  2. Put the valve at the bottom touching the ground and mark the ground.
  3. Roll the bike forward one full wheel rotation until the valve is back at the bottom.
  4. Mark the ground again and measure the distance between marks (in mm is easiest).

That distance is your circumference. It’s the same approach traditional bike computers use because it accounts for your
real tire size under your real weight.

Step 2: Distance per Rotation

Once you have circumference, distance becomes easy:

Distance (meters) = rotations × circumference (meters)

If your circumference is 2105 mm, that’s 2.105 meters. If you count 100 rotations, you traveled 210.5 meters.

Step 3: Speed from Time Between Pulses

If you measure time between two rotations (Δt), your speed is:

Speed (m/s) = circumference (m) ÷ Δt (s)

Convert to km/h by multiplying by 3.6, or to mph by multiplying by 2.23694.

Example (road bike-ish numbers):

  • Circumference = 2.105 m
  • Time per rotation (Δt) = 0.50 s
  • Speed = 2.105 / 0.50 = 4.21 m/s
  • Speed = 4.21 × 3.6 = 15.16 km/h (about 9.42 mph)

Notice what geometry did: it turned a “click… click… click…” signal into a real-world speed value with nothing more than
a circumference constant and a stopwatch.

Hardware Options: Two Simple Ways to Count Wheel Rotations

Option A: Reed Switch + Magnet (Cheap and Classic)

A reed switch is a tiny glass capsule that closes when a magnet passes by. It’s simple, inexpensive, and widely used in
basic bike computers. The tradeoff: it’s a mechanical switch, so it can “bounce” (rapidly flicker on/off) and it can be
more sensitive to vibration if your mounting is sloppy.

Option B: Hall Effect Sensor + Magnet (Clean Signals, Less Drama)

A digital hall effect sensor detects magnetic fields electronicallyno moving contactsso it’s typically more reliable at
higher speeds and rough roads. Many hall sensors output a clean HIGH/LOW signal, which is perfect for Arduino interrupts.

Display Choices

  • 16×2 LCD: big text, easy to read, a bit bulky.
  • Small OLED (SSD1306): crisp, compact, looks “real bike computer” instantly.
  • No display: stream data to Serial, log to SD, or transmit wirelessly.

Wiring and Mounting Tips That Save Your Sanity

Magnet Placement

Put the magnet on a spoke, as close to the hub as you can without it smacking the sensor. Closer to the hub means
less magnet “whip” and fewer alignment issues. Your wheel is already doing enough without becoming a tiny centrifuge.

Sensor Placement

Mount the sensor on the fork (front wheel) or chainstay (rear wheel). The key is consistent gap and alignment. For reed
switches, keep the magnet pass close. For hall sensors, check the sensor’s “active face” orientationmany boards have a
correct side.

Use Pullups and Keep Wires Calm

Long wires on a bike are basically antennas that listen to every vibration and electrical hiccup. Use a pullup resistor
(often the Arduino’s internal pullup works fine), route wires away from moving parts, and add strain relief so your solder
joints don’t become “disposable.”

Waterproofing Without Overengineering

A bike is a rain test rig with opinions. Put the electronics in a small enclosure, use heat-shrink on joints, and consider
dielectric grease or silicone for cable entry points. Also: don’t seal in moistureleave a tiny vent or use a gasketed case
designed for electronics.

The Arduino Sketch Logic (The “Don’t Miss a Rotation” Plan)

Interrupts vs. Polling

You can poll a sensor in the main loop, but at higher speeds (or if you’re updating a display and doing other tasks),
polling can miss quick pulses. Using an interrupt lets the Arduino react immediately when the sensor triggers.
For speedometers, that’s usually the cleanest approach.

Debouncing and Noise: The Bike Is Not a Laboratory

If you use a reed switch, you’ll likely need debouncing (either hardware with a small RC filter or software with timing).
Even hall sensors can get false triggers if the magnet wobbles or wiring is noisy. A simple, effective strategy is to ignore
triggers that occur too quickly to be physically possible.

For example, if your wheel circumference is ~2.1 m, and you know you’ll never exceed, say, 40 mph, you can compute the
minimum realistic time between pulses and reject anything faster as bounce or noise.

A Practical Code Skeleton

Below is a simplified logic example. It uses an interrupt to capture rotation events and calculates speed using the time
between events. (You can adapt it for LCD/OLED output easily.)

This approach keeps the interrupt fast (record time, increment count) and does the heavier math in the main loop. That’s a
classic embedded pattern: interrupts capture events, the loop does the thinking.

Calibration and Accuracy: Getting Numbers You Actually Believe

Where Error Comes From

  • Circumference guesswork: the biggest accuracy killer. Measure it.
  • Magnet alignment: inconsistent gap can create missed pulses (speed reads low) or double pulses (speed reads high).
  • Bounce/noise: extra pulses cause spikes.
  • Display smoothing: if you average too much, the readout lags; if you average too little, it jitters.

Simple Smoothing That Still Feels “Live”

Instead of showing speed from a single interval, average the last few intervals (like 3–5 rotations). That reduces jitter
without turning your speedometer into an emotional support number that updates once per minute.

Reality Check: Compare to GPS (Carefully)

GPS speed can lag and can be noisy at low speeds, but it’s a useful sanity check. Your wheel-based speedometer can be very
accurate once circumference and pulse detection are correctespecially on twisty paths where GPS sometimes struggles.

Extra Features That Make It Feel Like a Real Bike Computer

  • Trip distance: resettable counter for each ride.
  • Total odometer: store in EEPROM so it survives power-off.
  • Max speed: fun, slightly dangerous for your ego.
  • Average speed: total distance ÷ total moving time.
  • Auto-sleep: turn off display when no pulses for a while to save battery.
  • Battery monitor: especially helpful if you power it from LiPo or a USB pack.

Safety and Practical Notes (Because You’re Still Riding a Bike)

Mount the display where you can glance without taking your eyes off the road for long. Make sure the enclosure is secure,
wires aren’t dangling near spokes, and nothing can snag. Also, test it in a safe area before trusting it on a busy street.
Your speedometer should measure speednot create speed.

Real-World Build Stories and Lessons Learned (The “ of Experience” Section)

The first time I built an Arduino bicycle speedometer, I learned a humbling truth: bicycles are not gentle platforms for
electronics. A desk prototype is like raising a cactus. A bike prototype is like raising a cactus… on a trampoline… during
an earthquake. Everything that “works perfectly” indoors becomes suspicious outdoors.

My earliest mistake was trusting a circumference chart instead of measuring rollout. The speed reading was close enough to
feel correct, but it always driftedespecially after changing tire pressure. It turns out the tire’s effective rolling
radius changes with pressure and load, which changes your real circumference. When I finally did the rollout method (with
my normal riding pressure and my weight on the bike), the numbers snapped into place. The speedometer didn’t just get more
accurate; it got more consistent. That’s the real win.

Next came the “mystery speed spikes.” I’d be cruising calmly and the display would briefly claim I’d achieved a
Tour-de-France-worthy sprint. The culprit was a reed switch bouncing on rough pavement. On a workbench, the switch was
fine. On the road, vibration turned it into a tiny percussion instrument. The fix was a combination of better mounting
(zip ties are not structural engineering, as it turns out) and a software rule: ignore pulses that arrive faster than what
my bike could physically produce. After setting a realistic minimum pulse interval, the spikes disappeared.

Mounting was its own comedy. If the sensor and magnet alignment is too tight, your wheel becomes a moving target that
occasionally smacks the sensor. If it’s too wide, you’ll miss rotations and wonder why your “speed” drops whenever you hit
a bump. I eventually found the sweet spot by mounting the sensor solidly, then slowly rotating the wheel by hand and
watching the trigger indicator (a tiny LED or Serial output). Once it triggered reliably at slow rotation, I tested faster
by spinning the wheel and checking for missed counts. The lesson: test on the actual bike, not just on a
breadboard with vibes of optimism.

Waterproofing also taught me to respect weather. My first enclosure was “sealed,” which sounded great until a sudden
temperature change caused condensation inside the case. Water didn’t have to enter from outsideI trapped it inside. After
that, I used a gasketed case and paid attention to cable entry points, plus a tiny bit of ventilation so moisture wouldn’t
become a permanent roommate.

Finally, display updates matter more than you think. If you update too slowly, the speed feels laggy. Too quickly, and the
numbers jitter like they’ve had three espresso shots. A 250–500 ms update rate felt natural, especially with a light
averaging filter (like a moving average across a few intervals). That’s when the project stopped feeling like an Arduino
demo and started feeling like a real bike computerone powered by geometry, magnets, and the quiet satisfaction of making
π useful outside of math class.

Wrap-Up

A DIY Arduino bike speedometer is one of those rare projects that’s both educational and genuinely useful:
it blends geometry (circumference and unit conversion), electronics (sensors, pullups, interrupts), and
practical design (mounting, weather resistance, readability). If you can measure your wheel, count a pulse, and respect the
chaos of real-world vibration, you can build a speedometer that rivals basic commercial unitsand you’ll actually
understand how it works.

The post Arduino + Geometry + Bicycle = Speedometer appeared first on Global Travel Notes.

]]>
https://dulichbaolocaz.com/arduino-geometry-bicycle-speedometer/feed/0