How to get sensor info like name,partNumber in DF

Dear all,

I would like to get the sensor information such as the name, partNumber of the powermeter/speed sensor.

How to do that?

Many thanks

Frank

  • I tried this in onUpdate() but still get null.

    System.println("name:" + Sensor.getRegisteredSensors(Sensor.SENSOR_BIKESPEED).SensorInfo.name); //print for debugging

    Activity on/off doesn't help.

    I am sure I paired a speed sensor in the simulator.

  • Not sure how you have it paired and connected in the sim.  I'd try it on the actual Garmim with the sensor paired and connected to it.

    Many external sensors have a timeout where if they are inactive/not worn for a few minutes, they stop transmitting and sleep.

  • Thank you.

    I check the status in the simulator, please see the picture. I keep the wheel spinning during my test.

    I also tried downloading the DF to my 1040 and still cannot get this information...

  • Not sure about the 1040, but on some devices, you may need to do this in a background service and not in the DF itself.  Sensor.Info.temperature is that way.

  • I must admit - I am a newbie in Monkey C.
    I develop data fields only for Edges and started this year.
    I am always setting myself new tasks in the form of self-teaching projects.
    One of them is related to ANT+ and the possibilities. I wrote a tiny project where the data of my Stages powermeter is read out. After long try and errors it works now. It may not be professionally coded - but it works on my Edge 1040. (In the simulator I never tested it with ANT dongle...).
    I attach it here as zip.
    Maybe this will help you.

    Please note: it takes its time until the sensor sends the data for Serial etc...  and it takes a longer time to see the battery state - up to one minute! - at least with my Stages powermeter.

    (What you need is a ANT+ Listener class)

    TestPower.zip

    In return, if someone could show me the code for reading the Edge internal temperature, I would be extremely grateful.
    I've been working on this background thing for weeks without success....
    I attach this NOT WORKING project here as zip. Maybe some pro can look at it...

    Temperature.zip

  • Here's a simple data field with a background service to get the temperature from Sensor every 5 minutes. It's got a couple println calls so you can see what's happening in the sim (you need to playback a fit file with temp data there).  I've also run it on an edge 530.

    "--" indicates the background has yet to run, -100 indicates the background ran but there is no data.  .

    On an Edge that doesn't pair with a tempe. it's the internal temp, but with a tempe connected, it will show that.  Watches are different, where in many cases it will only show data if there is a tempe paired and connected, but on some, it will show internal if there is no tempe.  (on Watches, you can get internal with SensorHistory.getTemperatureHistory() in most cases, but the temp sensor is part of the baro altimeter, so no baro, no temp).  SensorHistory is only on devices with an API level 2.1.0 or greater.

    SensDF.zip

  • You're great!

    Thanks - it works on my 1040, too!
    (Temperature on the real device was shown immediately after turning on - no delay!)

    Next station: have it to integrate into my Edge datafield AllinOne.

  • Dear sir,

    Many thanks for your code, it works!!!