I can't read data from the cadence sensor

Hello. i can to get data from crank rev. but I can't calculate the time between their activation(last crank event time) - I don't understand how to implement this

how to implement this formula: Cadence = (Difference in two successive Cumulative Crank Revolution values) / (Difference in two successive Last Crank Event Time values

Service UUID: 00001816-0000-1000-8000-00805f9b34fb

Characteristic UUID: 00002a5b-0000-1000-8000-00805f9b34fb

I notice in your blocks that you are using a Clock Timer to repeatedly issue Read requests for Int values in BLE.

The usual design pattern I have seen in BLE projects is to issue a Register for Int requests once, then to sit back and let them arrive on their own sweet time via the BLE event block that triggers when a new Int value arrives (I forget the block name.) This lets you keep time with the transmitting sensor software (source code would be helpful) instead of your slow Timer drumbeat.

You will need 4 global variables to track the timing and crank readings:

  • old_crank_arrival_ms
  • new_crank_arrival_ms
  • old_crank_reading
  • new_crank_reading

In your event that captures an incoming crank int value, code:

  • set new_crank_arrival_ms to Clock1.SystemTime (ms)
  • set new_crank_reading to incoming int value
  • apply your formula using all 4 variables and display it
  • set old_crank_arrival_ms to new_crank_arrival_ms
  • set old_crank_reading to new_crank_reading
Revs=byte2+byte3*256
Time=(byte4+byte5*256)/1024

(editted by ABG to remove board butchery of the text)

Seeing your references to bytes in odd numbered locations (judging by their names),
that suggests that a stream of bytes would be easier to work with than a stream of Ints (2 bytes each?) misaligned with the byte pairs you are naming (assuming they start with byte1 and not byte0.)

This would be a good place to have a manual on the data stream to consult, to see how to see where one sequence of bytes ends and the next sequence of bytes starts.
Do you have one?


Please export your project and post it here.

I have an idea that might work if your cadence sensor is sending bytes,
and it would be easier to fit it into a copy of your app than to code it fresh.

Here is my best guess from what you gave me...

froood.aia (174.7 KB)