Main Content

ESP32 based computer for orbitrack that displays ECG shape and BPM charts, allowing to train at optimal load

At the end of 2021 I got an orbitrack - and immediately wasn’t happy about its in-built computer: not only it has poor visibility and no colors - but also its heart rate monitor works only when you keep hands on the bike’s handlebar, it has no contacts on vertical moving parts.

So I replaced it (in fact, did that a couple of weeks before the war hit, so shooting a video took just a bit longer than I anticipated)

Even though this way speed/distance/calories data look nicer than on stock computer, that’s not the main improvement. What is really important is that current heart rate is shown - both as a number and as a chart of BPM change over last 30 seconds - and most importantly, heart rate zone is color-coded.

In order to get that part done, I’ve used uECG device which our team created a couple of years ago. In fact any other BLE heart rate monitor can be used as well - they won’t give that nice ECG data, but they still output BPM and that’s what matters most in practical terms.

Heart rate zone defines how hard you are training and in which mode your body works. There is a lot of details here and heart zone is not the only decisive factor, but generally zones 1-3 indicate aerobic exercising mode, zones 4 and 5 indicate shift into anaerobic one. Roughly speaking, in zone 2 you can spend a long time burning fat, in zone 3 you improve endurance, in zone 4 you extend your physical limits and zone 5 should be avoided by non-professional athletes - but this is a really simplified and thus not completely true description.

In order to calculate heart zone, you need to know your resting heart rate - that one should be measured - and a maximum one, this can be calculated this way:

maximum heart rate = 207 - 0.7*Age

This itself is a certain simplification and doesn’t take into account fitness state of cardiovascular system of a particular person, but for many people it gives a good estimation.

In the program, resting and maximum heart rates are hardcoded (max_bpm and rest_bpm variables in the draw_functions.cpp file) and should be adjusted to your case. And those zones define color in which both ECG and BPM charts are plotted - in quite an obvious way, blue for 1st zone, then green, yellow, red and blinking purple/red for zone 5.

One effect is clearly seen from BPM and running speed charts: when the high load ends, BPM first increases and only in 10-15 seconds starts to decrease. This is one reason why heavy training shouldn’t be abruptly cut and gradual load decrease is necessary.

Speed counting is done by attaching to orbitrack’s revolution counter connector: it is a 2-pin connector which internally is connected to a simple switch. This switch is open through most of the revolution, and closes in certain point. So by connecting 1 pin to ground, 2nd pin to ESP input with pullup resistor activated, we see this pin going low once per revolution, while staying high all other time. Each time program detects high->low transition, it records time moment when that happened, compares to time when it happened previous time, and thus calculates revolution time - which in turn gives speed in revolutions per second.

Then this revolution speed is multiplied by some (quite arbitrary) coefficient to make it feel similar to a bicycle - anyway orbitrack is neither running nor cycling, so there couldn’t be some direct correspondence - and that’s it.

For calories calculation, I found some data on orbitrack calories burn vs “load intensity” - which is described in quite vague terms on itself - and just guessed coefficients to produce something that looks plausible (most likely calories calculation is wrong by 10-15%, but I hope error is not more than that)”

Link to article