BLE Peripheral : Cycle Speed & Cadence Sensor

Continuing the discussion from Implement BleAdvertisingDataType:

@ielec - do you have any advice or pointers as to where to start for the following project idea;

I’d like to emulate a Cycle Speed and Cadence Sensor using an Argon. Essentially the Argon would count the passes of a magnet on the wheel and crank. This could then be advertised, with the suitable uuIDs and connected to my phone (which would think it is a Speed / Cadence sensor).

I’ve had some experience with BLE Central mode (and help from @ScruffR) and these are now working well (uploading data from BLE sensor boards). Delightful. However when it comes to Peripheral mode I’m a bit stumped. I’ve made some initial progress, through vast reading (including this) from a number of sources, however am not getting data out. See code link.

I see the device coming up, and advertising as a peripheral, so that part is working, I just cannot get it to send data through on a regular basis. I realise the data is perhaps required to be sent together (both speed and cadence).

The maths behind the speed calculation leave to me, I suppose I’d just like to see something (data, even if constant) come up on nRFToolbox (under the CSC icon). See screenshot below.

Hi @neal_tommy,

Sorry for the delayed response. Without modifying your application linked above, the nRFToolbox cannot find the Argon acting as a Cycling Sensor, because the advertising data doesn’t contain the Cycling service UUID. It does contains before calling updateAdvertisingData(false); in setup(), but the advertising data is overridden by updateAdvertisingData(), since you construct a brand new advertising data object. You should get the current advertising data and then append the custom data in this function.

Despite of that, the application does can notify the simulated data if I use LightBlue App to connect to it. But neither I can see the data is updated in nRFToobox. I also have no idea what the App does in background after connected with your Argon. One step need to be performed before your Argon notifying data is that the characteristics with NOTIFY property should be enabled notification by mobile App, as I did manually on LightBlue.

Kind regards,
Guohui

@ielec - thanks for the reply. I managed to get a working version with a mix up of various code items. I wrote about it here.

It all works well, and I also managed to do some exercise with the device measuring speed and distance. I still have some work to do to get the cadence working (I’m on a single speed bike so the rear wheel will always turn in a fixed ratio to the pedals).

Thanks for your help!

1 Like