Turn Your Mini Exercise Bike into a Virtual Cycling Experience

Physical therapy or home workouts can sometimes feel monotonous. To combat this, we embarked on a project to inject fun and motivation into exercise using a simple Mini Exercise Bike. This guide details how to transform an inexpensive mini exercise bike into a virtual bike that adjusts video playback speed based on your pedaling, creating an engaging, game-like fitness experience.

This project is divided into two main components. First, we replaced the standard trip computer on the mini exercise bike with a custom-built module. This new module tracks pedaling motion and wirelessly transmits this data. Second, a computer-based video player receives this data and dynamically adjusts video playback speed to match your pedaling pace. Pedal faster, and the video speeds up; stop pedaling, and the video slows to a halt, simulating real cycling inertia.

Our aim was to utilize readily available components and minimize new purchases, making this a cost-effective and accessible DIY project for anyone looking to upgrade their mini exercise bike.

Understanding the Mini Exercise Bike Mechanics

Initially, I considered using magnets and a hall effect sensor to monitor the bike’s rotation. However, upon inspecting the original trip computer, I discovered a more straightforward mechanism. The internal wheel already had a magnet, and the trip computer used a magnetic switch to detect rotations. Testing this switch confirmed it was a simple magnetic contact. This discovery meant we could leverage the existing bike mechanism, simplifying our project to replacing the trip computer housing with our custom version.

The original trip computer unit of the mini exercise bike, which we replaced with our custom electronics.

Inside the original trip computer, revealing the basic components and wiring.

The magnet, a small silver circle, is clearly visible on the internal wheel, ready to trigger the magnetic switch with each rotation.

Close-up view of the magnet attached to the internal wheel of the mini exercise bike, used for rotation detection.

Designing and 3D Printing the Custom Case

My brother took on the task of designing the enclosure for our custom trip computer. A key requirement was to ensure compatibility with the existing socket on the mini exercise bike where the original computer was mounted. This would allow for a seamless installation without any modifications to the bike itself.

Our initial ambition was to create the smallest possible case. However, this proved challenging for iterative design and assembly. The final design, while somewhat larger than initially envisioned, fits securely and unobtrusively on the bike, ensuring it doesn’t interfere with the user’s exercise. To enhance durability during development and repeated assembly, we incorporated heat-press inserts. These inserts prevent screws from damaging the 3D-printed plastic over time.

The resulting case design prioritizes printability, ease of assembly, and user-friendliness.

Front view of the newly assembled custom trip computer case, designed for easy mounting and functionality.

Angled view of the completed custom trip computer, showing the robust and practical design.

Building the Smart Trip Computer Electronics

A core principle of this project was to utilize components we already had available. The TTGO T-Display board was an ideal choice due to its affordability and integrated screen. This ESP32-based board provides ample processing power for our simple trip computer display and Wi-Fi connectivity for data transmission.

We were able to directly integrate the magnetic switch from the original trip computer with the microcontroller pins. By configuring a pin as INPUT_PULLUP, we utilized the internal pull-up resistor, simplifying the circuit design.

For power, opting for a 9V battery and a buck converter offered a safer alternative to lithium batteries, especially for those newer to microcontroller electronics. The chosen buck converter accepts a wide input voltage range and features adjustable output voltage. Given our 5V output requirement, a 9V input provided sufficient headroom with a single battery.

During testing, while 5.0V seemed adequate, we encountered Wi-Fi instability. Slightly increasing the output voltage to 5.1V resolved this issue, ensuring reliable wireless communication.

While not strictly necessary, a prototyping PCB and headers provided convenient mounting solutions within the case and simplified component replacement, which proved useful when a T-Display board was accidentally damaged. Important safety note: Avoid connecting both the battery and USB power simultaneously!

The electronic components assembled for the virtual bike trip computer, showcasing the TTGO T-Display, buck converter, and wiring.

Software Design for Immersive Cycling

For the software, I wanted to explore LVGL, a user-friendly GUI library for embedded systems. The goal was to create a simple and intuitive setup process for the user. By employing UDP broadcasts, we eliminated the need for complex pairing procedures. The laptop and trip computer only need to be on the same Wi-Fi network. The trip computer broadcasts data packets containing a packet type identifier, a packet ID (incremented with each transmission), and the pedal cycle count. The video player then processes only packets with IDs higher than the previously received one, ensuring reliable data handling even with potential out-of-order delivery.

Network configuration is also simplified. No IP addresses are hardcoded; the system assumes a standard /24 network and dynamically determines the broadcast address by replacing the last octet of the device’s IP with 255. This ensures broad compatibility with typical home networks, broadcasting packets to all devices, with only the intended video player processing them.

For the video player, we leveraged the robust capabilities of Python, PyGame, and OpenCV. PyGame handles video presentation, while OpenCV with its FFMpeg integration enables decoding of a wide range of video formats. The player is optimized for 720p videos but supports various frame rates (tested with 30 and 60fps) and codecs, including h264 and h265.

The software dynamically adjusts video playback speed based on pedaling input. Each pedal rotation increases the target play rate, which gradually decays towards zero when pedaling stops, creating a realistic coasting effect. The actual play rate smoothly adjusts towards the target rate, preventing jerky transitions and providing a natural cycling feel.

On-screen circles visually represent the play rate. The green circle indicates the target 1x playback speed, and the red circle shows the current play rate. Initially intended for debugging, these visual cues provide valuable feedback to the user during their virtual cycling session.

To simplify user experience and eliminate the need for Python expertise, the entire video player application is packaged as a standalone .exe executable using PyInstaller.

The software delivers a user-friendly and feature-rich experience for virtual cycling. While prioritizing functionality and ease of use, the codebase reflects the project’s maker spirit, focusing on practical implementation over complex software engineering.

Curating Engaging Video Content

To enhance the virtual cycling experience, selecting appropriate videos is crucial. Platforms like YouTube host a wealth of walking tour videos showcasing scenic and historically significant locations. Channels like Follow Matty and Dave’s Walks offer excellent content. Videos with personal meaning to the user can further enhance motivation. We utilized YT-DLP to download videos and Handbrake to convert them to 720p, h265, CRF29, maintaining the original frame rate and using a constant frame rate to ensure smooth playback and manageable file sizes. This conversion process balances video quality with storage efficiency, suitable for viewing on a screen at a distance during exercise.

Optimizing Power Consumption for Extended Use

After initial use, we observed that battery life was shorter than desired. To address this, we explored power optimization strategies, including Wi-Fi power states, MCU sleep states, and display backlight dimming. Ultimately, reducing the microcontroller’s clock speed from the default 240MHz to 60MHz yielded a significant power reduction, dropping consumption from approximately 83mA to 73mA. This simple change provided a noticeable improvement in battery life. While further reductions were explored, lower clock speeds caused instability with the display initialization.

The T-Display board lacks direct brightness control, but it appears backlight control is possible via a GPIO pin. Exploring PWM-based brightness control could offer further power savings, but this remains a future enhancement.

Replicating the Build: Builds 2 and 3

The positive reception of the initial project led to requests from my brother and a friend to build their own virtual bike setups. We procured additional mini exercise bikes online and successfully replicated the project twice within a few hours, demonstrating the project’s replicability and straightforward assembly process.

Step-by-Step Build Instructions

Ready to build your own virtual mini exercise bike? Follow these instructions:

Code Repository: https://github.com/boristsr/VirtualBikeRides

3D Print Files (Case): https://www.printables.com/model/875892-mini-exercise-bike-esp32-virtual-convertion

Parts List (Approximate Total Cost: $102.62 AUD / ~$70 USD):

Item Name Model Number Qty Price (AUD)
DC-DC Supply Module LM2596 Buck Converter LM2596 DC-DC 1 $5.77
LILYGO® T-Display ESP32 Dev Board, 1.14 Inch LCD, WiFi/Bluetooth, Flash 4MB T-Display v1.1 1 $18.00
ElectroCookie Mini PCB Prototype Board Solderable Breadboard 1 $2.17
2.1 JST Connector 1
Male 2.54mm Bent Pin Header Right Angle Single Row 90 Degrees Needle Connector 1
9V Battery Connector 1
9V Battery 1 $2.49
Round Rocker Switch with LED Indication Red 20A 12V QY802-101 1 $6.25
Verpeak Mini Pedal Bike with LCD Display 1 $67.95
Wire, M3 screws, filament, heat press inserts, various tools

Assembly Steps:

  1. 3D Print the Case: Download and print the case files from Printables.
  2. Install Heat Press Inserts (Optional): For enhanced durability, install heat press inserts into the case screw holes.
  3. Assemble Electronics: Refer to the circuit diagram and images below for electronic assembly.
    • Voltage Regulator Adjustment: Crucially, adjust the LM2596 voltage regulator to 5.1V before connecting it to the T-Display.
    • Secure Adjustment: Apply Kapton tape or electrical tape over the regulator adjustment screw to prevent accidental changes.
    • Magnetic Switch Connection: Ensure the magnetic switch is connected to GPIO 21 (labeled ’21’ on the T-Display).
    • Strain Relief (Optional): Add a dab of hot glue to soldered wire joints to reduce strain, especially during iterative builds.
    • Header Offset: If using 10-pin female headers, offset them diagonally for better T-Display board support as shown in the images.
    • JST Connector: Note that some original trip computers use a JST connector for the magnetic switch, while others require cutting and adding your own JST connector.
  4. Flash Firmware: Flash the provided firmware to the T-Display before installing it in the case, as the USB port becomes inaccessible afterward. Important: Do not connect battery and USB at the same time!
  5. Firmware Test: Before full assembly, test the firmware by moving a magnet near the switch/probe to confirm the cycle counter increments on the screen.
  6. Case Installation: Carefully install the electronics into the 3D-printed case as shown in the images.
  7. Short Protection: Apply Kapton tape or electrical tape to any areas that could potentially short circuit, especially near the battery compartment.
  8. Magnetic Switch Positioning: Mount the magnetic switch as low as possible in the case to maximize proximity to the magnet on the bike’s resistance wheel. Testing and adjustment may be needed to ensure accurate rotation detection. Pedal and check if the counter on the screen increases.

Image showing the offset placement of T-Display headers for secure mounting.

Another view of the offset T-Display headers, highlighting the diagonal arrangement for stability.

The assembled internal electronics of the custom trip computer, ready for case installation.

Detailed circuit diagram illustrating the wiring connections for the virtual bike trip computer project.

Wiring Connections:

  1. Battery +9V to Rocker Switch Input
  2. Rocker Switch Output to LM2596 IN+
  3. LM2596 OUT+ to T-Display +5V (Pin 1)
  4. T-Display GND to LM2596 OUT-
  5. LM2596 IN- to Battery Ground
  6. T-Display GPIO 21 to Magnetic Switch (one terminal)
  7. T-Display GND to Magnetic Switch (other terminal)

Software Setup:

Detailed software deployment instructions are available in the project’s GitHub repository linked at the beginning of the build instructions.

Adapting the Project to Different Exercise Bikes

For adapting this project to other exercise bike models, consider replacing the magnetic switch with a hall effect sensor. Attaching one or more magnets to a rotating part of the pedal mechanism will enable similar rotation tracking. Using multiple magnets per rotation might require software adjustments but can provide finer-grained RPM estimation for enhanced responsiveness.

Future Enhancements and Project Expansion

This project offers numerous avenues for future development and improvements. Here are some potential expansions:

  • Power Consumption Reduction:
    • Implement Wi-Fi power-saving modes.
    • Utilize MCU sleep states for reduced power draw when idle.
    • Explore PWM control for display brightness adjustment.
  • Rechargeable Power: Transition to a rechargeable battery system for convenience and sustainability.
  • Battery Level Monitoring: Integrate a battery charge percentage monitor using a voltage divider and ADC to track remaining battery life.
  • Improved Battery Access: Design a screwless battery compartment hatch for easy battery replacement.
  • Housing Miniaturization: Optimize component layout and case design to reduce the overall size of the trip computer.
  • Enhanced Wi-Fi Configuration: Implement a Wi-Fi hotspot mode for easier configuration via smartphone if the pre-configured network is unavailable.
  • Video Player Software Upgrades:
    • Develop a more user-friendly UI.
    • Add a one-button adjustment for target pedaling speed.
    • Expand video resolution support beyond 720p.
    • Incorporate sound playback with potential pitch shifting or looped audio.
    • Implement a “buffering” mode, pausing video playback if pedaling slows, mimicking internet buffering.
    • Introduce interval training modes with guided high and low-intensity cycling periods.
  • Immersive Unreal Engine Integration: Create a compatible Unreal Engine environment where pedal speed controls movement through a visually rich virtual world, offering a more interactive and graphically advanced experience. While video tours offer sentimental value, an Unreal Engine integration opens up new possibilities for engaging virtual cycling environments.

By building this virtual mini exercise bike, you can transform a simple piece of fitness equipment into an engaging and motivating tool for therapy, workouts, and home fitness.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *