Spin Bike Controller

by doudar in Circuits > Microcontrollers

12170 Views, 37 Favorites, 0 Comments

Spin Bike Controller

install_step_3.jpg
on_bench_with_shifters.jpg
Communications_Overview.png

SmartSpin2K is an open hardware and software DIY module that converts BLE signals from a cycling APP (like Zwift, FulGaz, RGT, Sufferfest, etc.) and uses the information they broadcast to increase and decrease resistance on a spin bike by rotating the resistance knob with a stepper motor. SmartSpin2k receives BLE signals from common cycling peripherals such as HRM, power meters, and fitness bikes to rebroadcast BLE as a single stream to your chosen device. The system allows full smart trainer functionality with a simple spin bike and power meter.

Optionally, the SmartSpin2K project has also progressed to the point of where it's useful without the hardware as a BLE device multiplexer, heart rate to watt converter (estimator), and proprietary BLE device to normal FTMS protocol converter using only the readily available ~$6 ESP32 devkit.

More information, updates, discussion, cad files and software are located at the project github: https://github.com/doudar/SmartSpin2k/

Check out the build guide for a non PCB SmartSpin2k here!

Supplies

  1. ESP 32 Dev Board https://amzn.to/2ZNyjQX
  2. NEMA 17 Pancake Stepper https://amzn.to/37mKKHh
  3. TMC2225 https://amzn.to/3kctdEQ
  4. LM2596 Buck Converter https://amzn.to/33ofggY
  5. 24V Power Supply https://amzn.to/3r4e1i0
  6. Tactile Switches https://amzn.to/33ezmKx
  7. 608 Skate Bearings https://amzn.to/3isBzrW
  8. Power Meter(Optional so you can use it for fitness) https://amzn.to/3ioSjk7 (compatible with most pedals, some crank based meters
  9. The PCB from https://www.pcbway.com/project/shareproject/SmartSpin2k_PCB.html

Additional shop items

  1. 3.5mm stereo headphone connector
  2. 5.5mm x 2.1mm DC power connector
  3. (4) M3 x 8mm machine screws
  4. (4) #6 x 3/4" stainless wood screws
  5. (4) #4 x 1/2" flat head screws
  6. Stereo RCA to 3.5mm headphone "y" cable (used for shifter wiring)
  7. Hot glue

Print Parts

Case_PCB.png
All_Parts.png

PETG works well for all parts except the shifter straps. ABS will also work well.

Shifter straps need to be TPU.

Can also make shifters using other buttons. First version was just buttons covered in electrical tape and they worked okay.

You can find more information as well as the .stl files for the parts over at the projects github repository: https://github.com/doudar/SmartSpin2k/tree/master/Hardware

Build Wire Harnesses and Install Into the Case.

IMG_7236.jpg
IMG_7238.jpg

For the shifters, use a 3.5 mm headphone barrel connector for on one end and a 3 pin female connector on the other end. The longest wire is the common ground for the shifters.

Connect your power wires to a two pin connector on one end and to a female barrel connector (5.5mm x 2.5mm DC connector) that matches the 24V power supply. The wire harnesses should be 15-18 cm long. Make sure that the center connector is the positive wire. The positive pin on the PCB is the one closest to the edge of the board (and marked on the silkscreen).

Install Gear and Crossbar Onto Stepper

IMG_7239.jpg
IMG_7242.jpg

Press plastic gear down onto stepper driveshaft. Secure crossbar to stepper motor with two allen head screws sized M3 by 8mm.

Solder PCB

SmartSpin2k_TMC_Connections.jpg
SmartSpin2k_Esp32_Connections.jpg

Do NOT solder ESP32 and PCB together until ALL other components have been soldered to the PCB. Follow notes on PCB silkscreen for location and info on components. In testing, the board works with a wide range of capacitor values as the regulator we're using is robust.

The most important aspect is to make sure the one on the input side is rated at double your supply voltage (use a 50v rated capacitor).

The other capacitors only need to be rated at 10v (5v circuit) and are much easier to find.

The resistor needs to be a 1/4w 1k Ohm.

The voltage regulator is a recom R-78E5.0-0.5 https://www.mouser.com/ProductDetail/recom/r-78e50-05/?qs=JeAkOuORR2UvBuiB2kZVZQ

Install Pushbuttons Into Shifters

IMG_7244.jpg
IMG_7245.jpg
IMG_7246.jpg
IMG_7247.jpg
IMG_7248.jpg
IMG_7249.jpg

I've found that cutting the RCA plugs off of a 3.5mm to stereo RCA "Y" adapter cable is the easiest (and cheapest) way to make this cable.

Use a cable which is long enough to reach from your shifter location to your SmartSpin2k. Place push buttons into shifter housing, solder as indicated in the photos (so wires are diagonal to each other).

Trim the little square back cover so it fits easily into the back of the strap.

Add a fair amount of hot glue to the back of the button. Immediately put the back cover into position and (while the glue is still hot), depress the button numerous times to get a good button feel from the shifter.

Press Bearings Into Case

IMG_7237.jpg

Two bearings are pressed into the case. Make sure they are flush with the bottom of the case on the outside. You may need to do a small amount of sanding on the case so the bearings fit smoothly, but don't sand too much as we're relying on a nice "press fit" for retention.

Install Knob Cup Onto Gear Shaft

IMG_7250.jpg
IMG_7243.jpg
IMG_7251.jpg
IMG_7253.jpg

Insert 1/4" washer onto gear shaft to interface between knob cup and bearing on the outside of the case. If needed a washer can be installed on the gear shaft as a spacer inside to prevent rubbing. Make sure your gear shaft and knob cup rotate freely. A small amount of silicone grease is recommended on the gears.

Connect Wires to PCB

IMG_7254.jpg
IMG_7255.jpg

Make sure the red power wire is connected to the top pin on the PCB for power, with the black ground wire on the bottom.

Connect the stepper wiring harness to the 4 pins on the PCB.

Connect the 3 pins for the shifter to the PCB.

The middle pin on the shifter connector is the common ground to both switches.

Make sure to line the connectors up properly so all pins are in their respective pin connectors.

Insert PCB Into Case

IMG_7257.jpg

There are two small nubs on the SmartSpin2k case which will line up with the ESP32 at the bottom of the case. Lower the assembly into the case, then make sure the assembly tilts onto the nibs, then install two screws through the ESP32 to connect the assembly to the SmartSpin2k case. Use #4 x 1/2" flat head screws

Install Stepper Motor Into Case

IMG_7252.jpg
IMG_7258.jpg

The stepper motor can now be installed. make sure all wiring goes around the motor and does not interfere with the gears at the base of the case. Take care to install stepper without pinching any wire bundles. Routing the wires above the stepper crossbar should elimnate any interference with the transmission. Use two allen head M3 x 8mm screws to connect the stepper motor to the case through the holes in the bottom of the case. Tighten those two allen head screws gently. Use two #4 x 1/2" screws to connect the stepper crossbar to the case from the top. Tighten all screws securely.

Program ESP32

Download the SmartSpin2K firmware from github

Download the SmartSpin2K flash tool from github

Open the SmartSpin2K flash tool and flash the firmware.bin.

Connect to the new wireless network SmartSpin2K (password is password) and enter your home network information, then the ESP32 will finish the installation automatically.

Install Top Cover

Top cover installs with 4 #6 x 3/4" stainless wood screws.

Mount SmartSpin2K on Bike

Check your resistance knob is in a light resistance setting prior to mounting the SmartSpin2k. Using your customized knob cup insert in your knob cup, place the SmartSpin2k over the resistance knob of your spin bike. The rounded part of the case should face the rider. Install the bracket around the stem of the spin bike. Insert the shifter cable into the connector on the SmartSpin2k. Plug in the 24V power source and allow the device to power up. Press either shifter button. If the button you press increases resistance (rotates your knob clockwise), traditionally that is installed on the right handlebar. The other button can be tested to make sure it decreases resistance.

Initial Configuration

Initial_configuration_mobile_ios.jpg

So you have printed off your parts, followed the build guide, and powered up the SmartSpin2k for the first time. What's left?

On initial boot the SmartSpin2k will create its own Wifi network Access Point with the SSID of “SmartSpin2k”

The default password is **password**

The configuration page will automatically load on a mobile device. If you are not setting up on mobile, the configuration page can be found at http://SmartSpin2K.local/

Click on the **Settings** link

Enter your local WiFi network information with SSID and password. * The default network information is shown in this photo. The MDNS name is a name you can use to reach the SmartSpin2K on your network. For instance if you entered DansBike into the MDNS field, you could go to http://DansBike.local to bring up the SmartSpin2K web page.

On the next reboot, if the latest update is not installed, and the Wifi Network is connected to the internet, the SmartSpin2k will automatically update. You will notice the blue LED will flash quickly while this process occurs. It should take about 3 minutes. Once the blue LED is flashing slowly it is ready to pair bluetooth sensors. Should your local WiFi network not provide internet access, the SmartSpin2k will attempt to connect for 10 seconds, followed by reverting to the default SSID of “SmartSpin2k”.

Proceed to the wiki at https://github.com/doudar/SmartSpin2k/wiki/ to complete setup and find answers to common questions. Feel free to join the discussions, our community will be happy to help you get up and running! Happy Spinning!