Back to articles
Fitness

Smart Bike on a Budget (Work in Progress)

Converting a basic spin bike into a smart trainer with automated resistance: design and development progress.

November 15, 20254 min read
fitnessiotraspberry-pispin-bikeai
Share:
Smart Bike on a Budget (Work in Progress)

Smart bikes like Peloton cost $1,500–$3,000 and require monthly subscriptions. I have a perfectly functional spin bike, but the hassle of manually adjusting resistance during intervals keeps it from getting much use.

What if a Raspberry Pi and a stepper motor could solve that problem for under a few hundred dollars?

The Concept

Attach a small motor to the bike's resistance knob and control it via a web app during workouts.

Cost comparison:

SolutionHardwareMonthly
Peloton Bike+$2,495$44
Bowflex VeloCore$1,699$20
DIY PedalAI~$150$0

The economics are compelling.

System Design

PedalAI Hardware Architecture

Software Stack

ComponentTechnology
Web AppReact 18, TypeScript, Zustand
Device ControllerPython 3.11, WebSocket server
Local StorageIndexedDB (Dexie.js)
BluetoothWeb Bluetooth API
Cloud (Optional)Vercel Edge Functions

Safety Systems

Automated resistance control requires careful safety engineering:

  • Fail-Safe: Returns to minimum resistance within 500ms if communication is lost
  • Rate Limiting: Max 20% change per second (prevents jarring transitions)
  • Latency Target: Command-to-actuation under 100ms
  • Emergency Stop: Hardware button overrides all software

Key Features

Workout Management

Pre-Built Library:

  • Norwegian 4x4 (high-intensity intervals)
  • HIIT programs
  • Endurance rides
  • Recovery sessions

Custom Builder:

  • Define phases (warmup, intervals, recovery, cooldown)
  • Set target cadence and resistance for each
  • Save and reuse workout templates

Workout UI

Biometric Integration

The Web Bluetooth API connects to standard fitness sensors:

  • Heart rate monitors (Polar, Garmin, etc.)
  • Cadence sensors
  • 10Hz telemetry updates

Workout intensity adjusts based on heart rate zones.

Multi-User Profiles

  • Up to 5 users per device
  • Individual calibration settings
  • Separate session history
  • Personal analytics

Session Tracking

Every ride records:

  • Resistance over time
  • Heart rate zones
  • Cadence
  • Estimated calories/distance
  • Performance scores

Development Progress

Completed

Web App (100%):

  • Full PWA with offline support
  • Workout player and builder
  • Settings and calibration UI
  • Session analytics and history

Device Controller (100%):

  • Python WebSocket server
  • Motor control abstraction
  • Safety systems
  • Sensor integration

Waiting on Hardware

  • Raspberry Pi Zero 2 W
  • NEMA 17 stepper motor
  • A4988 motor driver
  • 12V power supply
  • 3D printed mounting bracket

Technical Challenges

Resistance Calibration

Every bike's resistance knob is different. The calibration wizard:

  1. User sets bike to minimum resistance
  2. Motor records position
  3. User sets bike to maximum resistance
  4. Motor records position
  5. Software maps positions to percentage

This creates a personalized resistance curve for each bike.

Why Open Source?

Commercial smart bikes are black boxes. If the company pivots, your bike becomes dumb again.

PedalAI is fully open source:

  • Modify workouts however you want
  • Add sensors the app doesn't support
  • Keep using it forever, no subscription

The code is mostly ready but some tweaks are likely needed. Once the hardware arrives and mounting is solved, the project will be documented end-to-end.

Next Steps

  1. Hardware acquisition: Parts mostly selected, almost ready to order
  2. Mounting design: A 3D-printed bracket would be ideal, but the initial PoC will likely use plywood, screws, and zip ties
  3. Integration testing: Software + motor + bike
  4. Calibration refinement: Real-world resistance curves
  5. Simulated AI coach: Adaptive resistance based on heart rate feedback
  6. Terrain visual profiles: Generate simulated hills and flats
  7. Documentation: Complete build guide

The goal is a reproducible project anyone with basic DIY skills can build. Smart fitness shouldn't require a $2,000 bike or a monthly subscription.

FullStackGrower

Appearance

Connect