Open source affordable cycling power meter
Just a small update.
As an alternative to Nordic soft device I tried to implement cadence and speed sensor using open source BLE stack. Apache mynewt with its NimBLE stack seemed to be worth giving it a try.
The result of my trials ended up in mynewt-core repository and can be found at:
I also decided to switch with development to newer nrf52 chip which has a bit more flash and RAM for debug features, higher resolution ADC, Cortex M4 core and lower energy consumption.
See some new tools and components in the picture below.
Finally I got some time to play around with some components that I have bought for this project.
In order to be able to calculate power one needs a realiable source of crank rotational speed. As the speed may vary over a single crank revolution, for precise measurement it is probably not enough to know only the period of crank rotation (average speed/cadence). It's not clear how often speed sampling should be, but using a MEMS gyroscope seems like a good idea.
But let's start with something simple. The idea is to build a cadence meter that works with my Polar V650 cycling computer.
MPU6050 comprises 3-axis accelerometer and 3-axis gyro in a single package. For this project only a single axis (at least or now) of MEMS gyro will be used. Z axis was chosen for the purpose of crank revolution measurement as it points perpendiculary to the surface of IC. The measurement of gyro indicates current rotational speed of the IC relatively to Z axis.
GY-521 module I2C interface was connnected drectly to nrf58122 GPIOs. Using nrfSDK TWI driver it was pretty easy to do basic MPU6050 register setup and start reading Z axis angular rate.
BLE service implementation was based on an example CSCS (Cycling Speed and Candence Service) provided in nrf SDK. Service configuration was altered to provide cadence only and simulated measurement was replaced with real cadence measurement from gyro.
Simplifying things a bit - BLE CSC service requires to expose crank revolution period expressed in 1/1024ths of second rather than actual cadence. It's up to client to convert it to human-readable RPM value. Revolution period was calculated by sampling gyro speed at 10Hz rate, averaging accumulated samples every second and converting speed in deg/s to single revolution period.
After solving some sampling rate and unit conversion issues it all worked pretty well.
Here is link to test ride: strava cadence test ride
Link to code: Gihub commit