Cycflix: Exercise Powered Entertainment
Now that the cheesy title has pulled you (Fitflix was taken and I didn’t want to be sued) I’ll tell you about the project, it uses a stationary exercise bike connected to an Arduino Nano to control the streaming of Netflix on a PC, I started this project hoping I could get it working on just a Raspberry Pi but ran into a few problems I couldn’t overcome which I’ll discuss at the end. But the main gist of the project at the click of a button and some user input, Firefox will open and play Netflix and monitor your speed for the Workout routine you designed, if you are going below the speed for too long, Netflix will be paused until you get back up to speed. If you want to use some other streaming service, it’ll only take a few changes.
The main reason I did this project was to learn some python and finally use my Raspberry Pi (which didn’t get used in the end) so the code won’t be perfect as I was learning as I went but thought I might as well publish the project.
- Arduino (any)
- USB Cable
- 10K resistor
- Copper Strip board
- Stationary Exercise Bike (can’t guarantee this will work with your bike)
- 2 Nuts and Bolts
Step 1: Speed Calculation
Before I started this project, I’ve never tried to hack into an exercise bike but I assumed it would output a variable frequency square wave or an analog voltage proportional to the speed, well it looks like my first guess was correct. But I thought it would be a rotary encoder which would be a high frequency due to the number of slots on the encoder but from my testing which I’ll describe below, the frequency of the square wave was very slow, at slower speeds the period of the wave was greater than a second. Either this is a very low resolution encoder, high gear ratio or something else, but it doesn’t really matter whats in the black box once we know how to use it .
I found out the output was a square wave with varying frequency from hooking up my Bitscope to the speed input of the display(which the manufacturers were nice enough to clearly label) and started pedaling. With the help of a friend, I took multiple screenshots of the waveforms at different speeds. To get the period of the square wave, measure the time between two rising or two falling edges(use TB in bottom left of window not Time/Div). From these waveforms, I found a formula to convert period of waveform to speed on the bike(these pictures are shown above). I did this by plotting the points on a graph and getting the equation from the treadline. You of course draw your own line of best fit, pick two point off the graph and solve:
y = m*x+C
Where y = Speed(Km), m is slope(Km/ms), x is Period(ms) and C is the offset (Km).
I rounded the slope and offset to this: Speed=Period*-0.0384+60.372
I did run into a problem that I couldn’t recorded the lower speed (around 10Km) because the frequency was so slow that the Bitscope couldn’t display the whole period. From my testing it looks accurate enough between 20Km and 40Km but below and above can be inaccurate making me think either the output is none linear, the display isn’t accurate or my formula is accurate. But it gives me close enough answers to the real value for most speeds, if I took more points, the equation would be more accurate but this will do.
Step 2: Circuit and Code
The circuit is very simple, its just a pull down resistor and two wires connecting to the speed input and ground of the bike circuit. There was four holes already in the back of the casing so I soldered my circuit to some copper strip board, drilled two holes in it and attached it to the casing with two nuts and bolts. If you do use copper strip board, make sure the traces are cut in between the Arduino pins and that the bolt doesn’t touch and of the copper.
For more detail: Cycflix: Exercise Powered Entertainment