• BLE CSC with mynewt

    Maciej Jurczak02/27/2018 at 22:18 0 comments

    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.

    New tools and components

  • Playing around with cadence measurement

    Maciej Jurczak11/19/2017 at 21:13 0 comments

    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.

    Components used:

    • BLE400 board with nrf58122 core module
    • 2xAAA battery holder & batteries
    • MPU-6050 /GY-521 MEMS module (gyro + accelerometer)
    MPU6050 module

    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. 

    All pieces connected and ready for testing

    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.

    Part of bluetooth CSC service specification

    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.

    Fixing bugs...

    After solving some sampling rate and unit conversion issues it all worked pretty well.

    Taped to crank arm, ready for a test ride

    Here is link to test ride: strava cadence test ride

    Link to code: Gihub commit