Measuring the Real Power of a Magnetic Exercise Bike
Reverse engineering the Bluetooth protocol of the Merach S26S, calibrating its eddy-current brake with spin-down tests, and rebroadcasting the calibrated data as an FTMS smart trainer through an ESP32.
The head unit of the Merach S26S computes power as the product of cadence and a tabulated coefficient indexed by a sensor on the resistance knob; the table is ordered backwards, so the reported power falls as resistance rises. Without a reference power meter, I estimated the real power with spin-down tests, using a crank revolution counter found in the bike's proprietary protocol. A model with constant friction and a speed-proportional brake describes every coast-down, and the brake coefficient grows exponentially with knob position. The calibrated data are rebroadcast in real time to a Garmin Edge 540 by an ESP32 acting as an FTMS smart trainer.
1Introduction
The Merach S26S is an exercise bike with a fixed-gear flywheel and an eddy-current magnetic brake, adjusted by a manual knob that moves the magnets towards the flywheel rim. Its head unit transmits cadence, speed, power and calories over Bluetooth Low Energy. In use I had noticed two inconsistencies: the reported power seemed barely sensitive to the resistance setting, and in the manufacturer's app the displayed resistance level appeared to decrease as the knob was tightened.
I set myself three goals:
- capture and decode all data transmitted by the head unit, and reconstruct how it is computed;
- estimate the real mechanical power without a reference power meter;
- make the corrected data available, in real time, to a Garmin Edge 540 and to training applications such as Zwift.
The work comprises the software (Bluetooth connector, dashboard, analysis tools and firmware) and the experiments on the bike. All data reported here come from sessions recorded on 19 November 2026.
2Data acquisition
The connector, written in Python with the bleak library, connects to the head unit, stores every notification in a raw session log and feeds a real-time web dashboard. On macOS, Bluetooth access requires a permission granted to the application hosting the process; the connector is therefore launched from Terminal, and the analysis runs on the recorded logs and on a local endpoint.
The bike advertises as MRK-S26S-XXXX and contains a ThinkFIT module exposing two data streams:
- the standard FTMS (Fitness Machine Service), whose Indoor Bike Data characteristic updates at about 1 Hz;
- a proprietary protocol on characteristic
FFF1, at about 5 frames per second, with power in tenths of a watt.
The proprietary protocol is undocumented; I decoded it by comparing it with the FTMS stream. Each frame is delimited by two fixed bytes and closed by a checksum equal to the XOR of the bytes in between:
02 | command | payload … | XOR | 03
| Frame | Bytes | Content |
|---|---|---|
0x42 live data | 2 | state: standby, running, paused |
| 3–4 | speed, 0.01 km/h | |
| 5 | resistance level 1–8 | |
| 6–7 | cadence, whole rpm | |
| 9–10 | power, 0.1 W | |
0x43 totals | 3–4 | elapsed time, s |
| 5–6 | distance, m | |
| 7–8 | energy, 0.1 kcal | |
| 9–10 | cumulative crank revolution counter (see section 5) |
A recorded frame and its decoding (two-byte fields are little-endian):
02 42 02 70 06 06 34 00 00 dd 08 00 00 d1 03
→ running · 16.48 km/h · level 6 · 52 rpm · 226.9 W
Every packet was logged in full, including fields not yet understood. This turned out to be decisive: one of the initially unknown fields is the crank revolution counter on which the calibration relies.
3The head unit's power model
The first minutes of logging already reveal two exact relations. Speed is always cadence multiplied by 0.317, whatever the resistance. The ratio of power to cadence is constant for a given level: in the example above 226.9 W / 52 rpm = 4.363 W/rpm, and the same value appears at level 6 at any cadence.
where \(c\) is the cadence in revolutions per minute, \(k(n)\) a tabulated coefficient indexed by the knob sensor reading, and \(d\) the virtual distance. There is no force or torque sensor.
Knob sweep
To determine the relation between knob position and the coefficient \(k\), I ran two sweeps at approximately constant cadence, the first around 38 rpm and the second around 60 rpm. The knob was moved from minimum to maximum one step at a time, about 20 s per position, and each position was logged as a marker in the session. At position 15 the emergency brake locks the flywheel, as described in the manual, so the usable range ends at position 14.
Show data
The two sweeps agree and fully characterise the behaviour of the head unit:
- Inverted level: the displayed level is 8 at the knob minimum and 1 at the maximum.
- Inverted power: at equal cadence the reported power goes from 302 W at position 0 to 84 W at position 14.
- Sensor saturation: positions 0 to 4 produce the same reading and are therefore indistinguishable.
- Instability at level boundaries: 64 level changes in 12 minutes, caused by noise in the reading.
- Tabulated power: \(k\) takes 11 discrete values between positions 4 and 14, from 5.028 to 1.527 W/rpm, in decreasing order.
- Nominal speed: 0.317 km/h per rpm corresponds to 0.88 m per flywheel revolution, i.e. a 28 cm diameter, whereas the flywheel measures 38 cm.
- Nominal energy: 15 kcal per virtual kilometre, hence a function of cadence alone.
- Averaged cadence: frames arrive at 5 Hz, but the cadence value updates about every 3 s and is always an integer.
4A first empirical correction
The most immediate correction is to invert the table, assigning the highest coefficient to the hardest position:
The resulting trend is correct (from 92 W at position 0 to 277 W at position 14, at about 60 rpm). Since the table has 11 fixed steps between positions 4 and 14, the knob position can also be recovered from \(k\) without entering it manually; below position 4 this is not possible, because the sensor is saturated.
However, the correction is still built on the manufacturer's coefficients, with an estimated uncertainty of 30–40 %, and it is physically inadequate: the torque of an eddy-current brake depends on flywheel speed, whereas the model \(P = k\,c\) assumes constant torque. Estimating the real power required a measurement independent of the head unit's coefficients.
5Requirements for an independent measurement
The reference instrument would be a pedal-based power meter, which I do not own. The available Garmin sensors were not usable: the speed sensor must be mounted on a hub, which a solid disc flywheel does not have, and the frame leaves no room on the rim; the cadence sensor transmits only over ANT+, which the Mac cannot receive without a dedicated receiver.
The chosen method is the spin-down test, used to calibrate magnetic trainers: the flywheel is brought to high speed and left to coast freely, at each knob position. The deceleration profile determines the braking torque; with the inertia known, torque converts to power. Two features of the bike simplify the measurement: the drivetrain is fixed (pedals and flywheel are linked by a belt with no freewheel), and the ratio is exactly 6 flywheel revolutions per crank revolution, verified by direct counting.
The method requires the time of each revolution during the coast-down. The head unit's cadence does not meet this requirement:
A coast-down lasting a few seconds would yield one or two values, already averaged between motion and standstill.
The crank revolution counter
Bytes 9–10 of frame 0x43, initially uninterpreted, turned out to be a cumulative crank revolution counter. The hypothesis was checked on the 21:00 sweep: the counter went from 0 to 317, while the time integral of the reported cadence gives 321 revolutions over the same interval, a 1.2 % difference consistent with the rounding of cadence.
The counter keeps incrementing during the coast-down, up to the last complete revolution before standstill. The spin-down test can therefore be performed with the bike's own instrumentation, without external sensors.
6Physical model of the coast-down
Braking torques
With no input on the pedals, two braking torques act on the flywheel–crank system:
- mechanical friction in the belt and bearings, modelled as a constant (Coulomb) torque, independent of speed and knob position;
- the eddy-current brake: the conducting rim moving through the magnets' field carries induced currents which, by Lenz's law, produce a force opposing the motion. Below the brake's critical speed the force is proportional to velocity:
with \(\sigma\) the conductivity of the rim material, \(\delta\) its thickness, \(B\) the magnetic field in the air gap and \(v\) the rim velocity.
Equation of motion
With \(\omega\) the crank angular velocity, \(I\) the system inertia referred to the crank and \(n\) the knob position, the rotational equation of motion is
Dividing by \(I\) gives an equation with only two parameters, both determinable from timing measurements:
Solution
The equation is linear and first-order. With \(\omega(0)=\omega_0\) at the moment of release:
The counter measures angles travelled (one increment every \(2\pi\) radians); integrating:
The crank stops after a time
The exponential term, associated with the magnetic brake, dominates at high speed; the linear term, associated with friction, dominates over the last revolutions. The two components thus leave distinct signatures on the same curve \(\theta(t)\), which makes it possible to separate them even from a single spin.
Power
At constant speed the torque applied by the rider equals the braking torque, so the power delivered is
The magnetic term grows with the square of angular velocity. The head unit instead assumes power proportional to cadence, and therefore underestimates the increase in power at high cadence.
Inertia
Spin-down tests determine \(a\) and \(b\), i.e. torques divided by inertia; absolute power requires \(I\). The product sheet states a 6 kg flywheel; the measured outer diameter is 38 cm and the thickness 3 cm, with a plastic shell. A solid steel disc of the same size would weigh about 27 kg:
The stated mass is therefore concentrated in a metal ring under the shell, a typical arrangement for eddy-current flywheels. The two limiting cases, mass distributed uniformly and mass concentrated at the rim, give:
I adopted the central value of 0.15 kg·m². Referred to the crank, the flywheel inertia must be multiplied by the square of the gear ratio \(G\), as follows from equating kinetic energies with \(\omega_{\text{flywheel}} = G\,\omega\):
The uncertainty on \(I\), about ±25 %, carries over directly to the absolute scale of every power estimate, since \(P \propto I\).
7Preliminary tests
A first set of three spins, at positions 0–4, 7 and 14, was meant to verify that the coast-down lasts enough revolutions for a fit. The figure shows the duration of each revolution as logged by the counter.
Show data
At position 0 the crank, released at about 180 rpm, completes some fifteen free revolutions in 10.6 s before slowing to 30 rpm; at position 7, nine revolutions in 5.2 s; at position 14 it stops almost immediately, because the brake is already in contact with the flywheel.
A first fit, expressed per unit inertia, shows that at 60 rpm the braking at position 7 is 2.5 times that at position 0. The head unit's table implies the opposite ratio; the inverted table of section 4 gives 1.7, so it too underestimates the growth of resistance. With \(I = 5.4\ \text{kg}\cdot\text{m}^2\) the first absolute powers are:
| Knob | Head unit, 60 rpm | Inverted table | Spin-down, 60 rpm | Spin-down, 90 rpm |
|---|---|---|---|---|
| 0–4 | 302 W | 92 W | 42 W (30–49) | 75 W |
| 7 | 233 W | 157 W | 86 W (62–123) | 195 W |
The ranges correspond to the two limiting cases for inertia. The tests also allow a consistency check of the reported values: dissipating 302 W at position 0 and 60 rpm (\(\omega \approx 6.28\) rad/s), with the measured friction and brake, would require an inertia of
corresponding to a flywheel of more than 30 kg, against the stated 6 kg. The head unit's values are therefore incompatible with the observed flywheel dynamics.
In these tests the crank was brought up to speed by pedalling and then released by lifting the feet off the pedals; the coast-down starts at that instant. With a fixed drivetrain the pedals keep turning during the coast-down: anyone repeating the test should consider the safer alternative of spinning the crank by hand from the side of the bike.
8Calibration series
The calibration series comprises one spin at each even knob position from 0 to 14, with positions 0 to 4 entered manually in the dashboard. To avoid relabelling after the fact, the series was recorded in a dedicated session, discarding an earlier attempt that contained a marker error. Release speeds range from about 150 to 200 rpm.
At positions 10, 12 and 14 the coast-down has 4, 3 and 3 revolutions respectively: too few to estimate the initial speed, friction and brake coefficient independently for each spin.
Estimation procedure
The estimation introduces two physically motivated constraints:
- Friction shared by all spins. Belt and bearings do not depend on knob position, so \(a\) is a single parameter, chosen to minimise the total error over all spins; only \(b\) remains to be estimated for each spin.
- Estimated release time. The instant \(t_r\) at which driving ends is included among the parameters, under the constraint that after the last logged revolution the crank cannot complete another one.
For each spin, given the times \(t_i\) of the logged revolutions, the objective function is
where \(\theta_{\text{mod}}\) is linear at constant speed \(\omega_0\) before \(t_r\) and follows the solution of section 6, with the shared friction \(a\), afterwards. The result is \(a = 0.80\ \text{s}^{-2}\), i.e. a friction torque of 4.3 N·m at the crank and about 27 W at 60 rpm. The RMS residuals of the individual spins range from 0.02 to 0.23 revolutions.
The figure below shows the spins of the series, revolution by revolution, together with the fitted model. The axes are fixed so that knob positions can be compared.
Show data
9Brake dependence on knob position
The values of \(b\) estimated at the different positions lie on a straight line on a logarithmic scale:
Show data
Linear regression of \(\ln b\) on position \(n\), over 7 spins, gives:
with coefficient of determination \(R^2 = 0.997\), a scatter of 6 % about the line (1σ, residuals within ±8.4 %) and a 95 % confidence interval for \(r\) of 1.239–1.277. The brake therefore strengthens by a factor of 1.26 per step, about 25 times between positions 0 and 14.
The exponential trend has a physical justification. The magnetic field in the air gap decreases approximately exponentially with the distance \(g\) between magnets and flywheel, the braking torque is proportional to \(B^2\), and each knob step reduces the distance by a constant increment \(\Delta g\):
The complete model is defined by four parameters, stored in the file calibration.json:
with \(\omega = \pi c/30\) the crank angular velocity in rad/s and \(n\) the knob position.
10Results
I applied the three power estimates (head unit, inverted table and calibrated model) to the 60 rpm sweep of section 3.
Show data
The calibrated model rises slowly up to position 10 and steeply beyond it, consistent with the effort perceived during the test; the head unit shows the opposite trend. The two curves cross around position 10.
Energy was recomputed as well. The head unit derives it from the virtual distance, and hence from cadence alone; the model instead allows the mechanical work to be integrated and converted to metabolic energy, assuming a typical gross efficiency of 24 %:
Over the 60 rpm sweep (5 min 25 s of pedalling) the work is 43.5 kJ, about 43 kcal, against the 67 kcal reported by the head unit. Average power is 134 W and the best minute 292 W.
Calculator
The calculator below applies the calibrated model and compares it with the head unit's table for the selected position and cadence.
11Uncertainty analysis
| Source | Affected quantity | Magnitude |
|---|---|---|
| Flywheel inertia (0.11–0.17 kg·m²) | absolute scale of all powers, \(P \propto I\) | ±25 % |
| Spin repeatability (knob 0: 43, 49 and 42 W at 60 rpm) | single estimate of \(b\) | ±8 % (1σ) |
| Scatter about the exponential law | \(b\) at a single position | ±6 % (1σ) |
| Extrapolation to positions 12–14 (0–2 free revolutions) | power at position 14, 60 rpm | 302–447 W, central 367 W (95 % CI on \(r\)) |
| Positions 0–4 not detected by the sensor | power at 60 rpm between 41 and 65 W | depends on manual entry (default: 2) |
| Cadence averaged over about 3 s | power during rapid changes | smoothing; no effect at steady state |
| Counter resolution (0.2 s) | revolution times | absorbed by the fit over 10–25 revolutions |
The ratio of two powers measured under the same conditions does not depend on \(I\). For comparisons between sessions, for instance to assess an improvement in sustainable power, the relevant uncertainty is therefore the relative one, of the order of 6–8 %, rather than the scale uncertainty.
The model assumes constant friction and a magnetic torque linear in \(\omega\). Over the range explored, from 30 to about 200 rpm at the crank (up to about 20 m/s at the flywheel rim), these assumptions reproduce the spins with the residuals reported in section 8; validity beyond this range has not been verified.
12Alternative methods considered
To reduce the scale uncertainty, several methods for measuring inertia or friction directly were evaluated. None was carried out; for each, I give the principle and the reason it was excluded.
Physical pendulum
A known mass attached to the pedal, released from about 45° and filmed to measure its period, would give the inertia directly:
with \(L\) the crank length. The method is not applicable because of friction: in an oscillator with Coulomb friction the amplitude decreases, at each half-oscillation, by
With 10 kg, \(L = 0.17\) m and the measured friction torque of 4.3 N·m, this gives \(\Delta\theta \approx 30°\): starting from 45°, the pedal would stop before completing one oscillation.
Equal masses on both pedals
Two identical masses on opposite pedals balance each other statically and increase the inertia by a known amount, \(\Delta I = 2mL^2\); comparing coast-downs with and without the masses would yield \(I\). The sensitivity, however, is insufficient:
With 5 kg per pedal the change is of the same order as the spin repeatability (section 11).
Static friction measurement
A mass hanging from the pedal measures the friction torque in N·m; combined with \(a = \tau/I\) from the coast-downs, it yields the inertia with no assumption about the flywheel's construction:
Two variants were considered. In the first, one looks for the minimum mass for which the pedal, starting horizontal, keeps descending after a slight push: \(m g L = \tau\), about 2.6 kg predicted at position 0. In the second, more objective, one looks for the minimum mass that takes the pedal from horizontal to vertical; the potential energy lost over the quarter turn is entirely dissipated by friction:
The method was excluded for practical reasons: it requires masses of several kilograms already at position 0, to be determined by repeated weighings at several knob positions.
Other references
- Heart-rate-based calories (Garmin Epix watch): uncertainty of 15–20 %, sufficient only to detect gross scale errors.
- Manufacturer's manual: does not describe the internal structure of the flywheel, which would have allowed a choice between the two limiting inertia cases (expected uncertainty ±10–15 %). It confirms the fixed drivetrain, the emergency brake and the 15 kcal per kilometre rule.
- External instrumentation: a pedal power meter, an ANT+ receiver for the cadence sensor, importing the Edge's .fit files. The first would remove the scale uncertainty; the other two were made unnecessary by the revolution counter.
13Implementation: dashboard and virtual trainer
Dashboard
The dashboard gives prominence to the quantities computed by the model (power, energy, cadence, knob position) and to a session summary. The head unit's power is shown only as a reference in the charts, and the remaining head unit data are grouped in a separate section marked as unverified. Recorded sessions are recomputed with the current calibration.
Virtual trainer “Better_Merach”
The third goal required a Bluetooth device rebroadcasting the calibrated data in real time, recognised by the Garmin Edge 540 and by Zwift. The virtual device was named Better_Merach. The first implementation used the Mac as a Bluetooth peripheral and ran into three successive limitations.
- Advertising packet length. A Bluetooth LE advertisement holds at most 31 bytes. The first library used encoded service identifiers as 128-bit UUIDs (16 bytes each): two services already take 34 bytes, and macOS truncated the name and dropped the services. A GATT server written directly on CoreBluetooth, with standard 16-bit identifiers (
0x1818for power,0x1816for speed and cadence), solved the problem; the Edge, however, paired the device as a plain power sensor. - FTMS service data. To carry cadence, speed and distance as well, the device must present itself as an FTMS smart trainer. Advertised alone, the FTMS service was not listed by the Edge. Comparison with the bike's advertisement, which the Edge recognises as a trainer, revealed a service data block,
1826 → 01 20 00(machine available, indoor bike type), defined by the FTMS specification. When acting as a peripheral, macOS advertises only the local name and the list of services: the block is accepted by the API but not transmitted. - One sensor type per address. As an alternative, two separate standard sensors were advertised, speed/cadence and power. The Edge paired the first but not the second: it associates a single sensor type with each Bluetooth address, and the Mac exposes only one. The Edge also reports the device name as the computer's name, which macOS provides in the GAP service.
ESP32 bridge
The adopted solution is an ESP32 board connected to the Mac over USB, on which the advertisement can be composed byte by byte. The board is a classic ESP32 (ESP32-D0WDQ6, Bluetooth and Wi-Fi, 4 MB flash), running MicroPython 1.29. Because opening the serial port resets the board, the standard mpremote tool could not establish a connection; a client that waits for boot to complete before taking control was written to upload the firmware.
26 18 is 0x1826.The MicroPython firmware, about 150 lines long, exposes the FTMS, Cycling Power and Device Information services and accepts up to three simultaneous connections, for example the Edge and Zwift. All processing (decoding, calibration, packet encoding) runs on the Mac, which once per second sends the board a line of text over USB serial with the packets already encoded; the board retransmits them and reports its status every two seconds.
5 frames/s
1 line/s
FTMS
Mac → ESP32 N <indoor_bike_data_hex> <cycling_power_hex>
ESP32 → Mac S {"fw": "better_merach-1", "conn": 1, "adv": 1, "age": 0}
FTMS control point commands, such as resistance changes requested by Zwift, are acknowledged but not executed: resistance remains set manually by the knob, so ERG mode is not available.
Conformance of the advertisement was verified in two ways. The connector's own scanner, which selects the bike by FTMS service and service data, classified the board as equivalent to the bike; a rule excluding Better_Merach devices from the search was therefore added. Subsequently the Garmin Edge 540 paired Better_Merach as a smart trainer, receiving power, cadence, speed, distance and calories; the first values rebroadcast were 32 W, 45 rpm and 16.1 km/h at position 2.
Virtual speed
On an indoor bike speed is necessarily a derived quantity. The virtual trainer transmits the speed that would be reached on flat ground, with no wind, at the estimated power, by numerically solving the balance
with \(C_{rr} = 0.004\), \(C_dA = 0.32\ \text{m}^2\), \(\rho = 1.225\ \text{kg/m}^3\) and \(m\) the combined mass of rider and road bike, set in the dashboard. At 85 kg, 100 W corresponds to about 26 km/h, 150 W to about 31 km/h and 250 W to about 37 km/h.
Source code
The connector, dashboard, calibrated model, ESP32 firmware and calibration tools are published under the MIT licence, together with documentation of the protocol, the calibration method and the virtual trainer:
The calibration can be reproduced on other units with the same head unit: after a series of coast-downs, one per knob position, the analysis script performs the fit and writes the calibration.json file.
.venv/bin/python tools/spindown.py <session> --save
14Conclusions
The main figures obtained in this work are summarised below.
- The Merach S26S head unit does not measure power: it computes it as the product of cadence and a tabulated coefficient ordered backwards. Speed and calories are functions of cadence alone.
- The reported powers are incompatible with the flywheel dynamics: at position 0 and 60 rpm they would require an inertia about seven times larger than the estimated one.
- Spin-down tests based on the revolution counter in the proprietary protocol allow power to be estimated without external instrumentation. A two-parameter model, with constant friction and a brake linear in speed, reproduces every spin.
- The brake coefficient grows exponentially with knob position, by a factor of 1.258 per step, consistent with the decay of the magnetic field with distance.
- The absolute uncertainty (±25 %) is dominated by the flywheel inertia; the relative uncertainty, which matters for comparisons between sessions, is of the order of 6–8 %.
- The calibrated data are available in real time on the Garmin Edge 540 through an ESP32 acting as an FTMS smart trainer, a configuration that cannot be achieved with macOS Bluetooth alone.
The main future development is a comparison session against a pedal power meter, which would fix the absolute scale and allow the model to be verified at positions 12–14, which are currently extrapolated.
References
- Bluetooth SIG, Fitness Machine Service (FTMS), specification 1.0.
- Bluetooth SIG, Cycling Power Service and Cycling Speed and Cadence Service.
- Apple Developer Documentation, CBPeripheralManager, method
startAdvertising(_:): supported advertisement keys. - MicroPython,
bluetoothmodule for ESP32, version 1.29. - Project repository: github.com/lucacava/merach_device, documents
docs/protocol.md,docs/calibration.md,docs/virtual-trainer.md.