How to test for presence of cadence sensor without requiring the user to be pedaling?

Former Member
Former Member
How to test for presence of cadence sensor without requiring the user to be pedaling?

If I use Sensor it will always report not null.
If I use Activity it will return null even if sensor is present and has returned a value.
  • Former Member
    Former Member over 8 years ago
    If what you want is to get/show cadence value, you just need to get value from compute(info), then info.currentCadence will return what you want.

    For testing purpose, you have 3 way to do so:
    1. Load your FIT file contains the values you want to debug and show;
    2. Use simulate values (recommanded);
    3. If you implement entire ANT+ connection to Cadence sensor or Power Meter sensor, you can get Cadence value from ANT+ also. And after you using an ANT+ dock, the actual sensor will give what you want.
  • Former Member
    Former Member over 8 years ago
    Thank you. I should have mentioned this is for an Application, which means that compute() is not available to me. I would also suspect that since compute() returns Activity.Info that it would also return null when cadence is 0.
  • I've only used cadence in apps for walking/hiking/running, but there can be variations spaced on the SPORT_ you are using for the session.

    For example, with SPORT_HIKING, currentCadence is actually in "revolutions" and not steps, and must be doubled to get steps, and for all I mentioned, averageCadence is in revolutions. And the numbers are incorrect in the sim (maybe based on the .fit you are using), but fine on a device.

    What SPORT_ are you using?
  • Former Member
    Former Member over 8 years ago
    Cycling jim.

    What I want to do is confirm that the device has found a cadence sensor before the user starts the session. However there appears to be no way of confirming a cadence sensor has connected unless the user is pedaling. If the cadence sensor has connected, but the cadence is 0, then there is no way of knowing the sensor has connected.

    I specifically want to have icons showing the devices as they connect. When all the devices have connected then the user can start recording. I have no problem with any of the other sensors, just cadence.

    I hate to have to remove the whole icon display, but I do not want the inconsistency of having 1 sensor that does not report like all the others, so therefor I must. It's just slightly annoying to have put the time into something that works in the simulator, only to find that it does not work on devices.
  • It sounds similar to something I was trying to figure out maybe 14 months back - but it had to do with the footpod and never found a good solution.

    While setEnabledSensors() will tell you what's paired, there's no common way to find if that sensor is connected (I too was looking at doing icons)

    For things like the Tempe and HRM, you can tell they are connected because you start getting data. (not connected, no data)

    For the footpod however, you can't tell, as if it's not, you'll still get cadence data, but from the watch. (in the api-doc for sensor.info, cadence has an "order" of what is passed, but no indication of the source ( bike, dynamic sensors, footpod, and the watch), so you fall back to the watch's cadence if nothing is connected)

    For the sensor your using, is it like a footpod where it doesn't xmit while it's in battery saving mode, and needs to be woken up with movement? Do you have to peddle a bit when you are first trying to pair it?

    The native apps can show when sensors are connected, but in CIQ I've not found a way to do that with something like a footpod.
  • Former Member
    Former Member over 8 years ago
    I suspect the problem is firmly rooted in the CIQ cadence sensor code. Like you say the other sensors are fine, just those cadence related. The actual sensor can be awake, it doesn't matter. You can pedal and see the info return a value, then stop pedaling and wait a few seconds and see the return value change to null. Once connected returning null is incorrect IMO, because 0 is the correct value.

    I don't understand what you mean by setEnabledSensors() will tell you what is paired. Is it not that you tell setEnabledSensors(array) what to try and pair?
  • I don't understand what you mean by setEnabledSensors() will tell you what is paired. Is it not that you tell setEnabledSensors(array) what to try and pair?


    setEnabledSensors returns an array of the sensors that are paired.

    so if you did:

    var paired=Sensor.setEnabledSensors([Sensor.SENSOR_TEMPERATURE]);

    "paired" will be [] if there isn't a Tempe paired, but will be [Sensor.SENSOR_TEMPERATURE] is there is one paired even if it's miles away.
  • Former Member
    Former Member over 8 years ago
    My bad. I was thinking you meant in the live sense. It's getting past my bedtime again.