Water depth with instinct 2

Good afternoon all 

My instinct2  has the same barometer sensor as the G1 so iv been told. Im trying to make a water depth data field, but the simulator app crashes. I'm fairly new to monkey c could one of you experts read  it over and tell me where im going wrong 

import Toybox.Activity;
import Toybox.Lang;
import Toybox.Time;
import Toybox.WatchUi;
import Toybox.Sensor;

class valueView extends WatchUi.SimpleDataField {

    function initialize() {
        SimpleDataField.initialize();
        label = "Water depth M";
    }

     var x = Activity.getActivityInfo().ambientPressure;
     var y = ((x - 1013)/9.9) ; //1013 average sea level pressure Pr, h=(P-Pr)/(rho * g '=9.9') 
    function compute(info as Activity.Info) as Numeric or Duration or String or Null {
        return y ;
    }

}

  • Pressure is not directly related to altitude and calibration occurs based on GPS, but GPS isn't that great for altitude.

    You can be at the exact same spot and pressure changes.  If you look at altitude (after using GPS for something, is it correct?

  • When you hear the pressure on a weather report, that's often the sea level pressure as the altitude will result in different pressurs with ambien.  So there is also meanSeaLevelPressure and that too is available:

    var meanSeaLevelPressure as Lang.Float or Null

    The mean sea level barometric pressure in Pascals (Pa).

    This returns barometric pressure calibrated to sea level. Since pressure varies dues to several factors, a GPS-based altitude must first be obtained, then the ambient (local) pressure is measured by the pressure sensor before conversion to a calibrated barometric pressure value.

  • I' not sure Garmin had this (arguably interesting idea) in their mind when they released the pressure data in the sdk. It's mainly for calculating altitude changes during activity or counting how many floors you climbed. It'll be interesting to see how accurate it'll work for calculating water depth. Though there's the Descent watch that seems to be marketed towards divers.

  • Devices can limit the data under water so it can't be used for diving,  Only Descent devices have been certified for that.  In app approval exceptions it specifically talks about diving apps.

    https://forums.garmin.com/developer/connect-iq/w/wiki/10/app-approval-exceptions

    Apps designed for scuba diving, free diving, skydiving, base-jumping, and extreme flight sports will not be listed on the app store for the following reasons:

    • The diving features available on the Descent Mk1 are the only Garmin features intended for underwater diving use.
    • The altimeter/barometer feature available in some Garmin devices is intended to be used for general altitude reference only, and is not intended to be used for extreme sports such as skydiving, base-jumping or other activities that require the use of equipment that is designed and intended for such use. The Jumpmaster feature on the Garmin tactix Bravo watch is intended to be used for skydiving activities by experienced skydivers. This is the only Garmin feature that is intended for use while skydiving.
  • That's seems to give accurate results now with the code below just putting in an offset. It would be good to just be able to read barometer after correction/calibration like the suunto watches. Yes i appreciate you should not rely on this data for any critical activities. I had looked at the G1 and had my finger was on the bin button but could not justify it for a swimming pool and the occasional snorkelling. Thanks  

    import Toybox.Activity;
    import Toybox.Lang;
    import Toybox.Time;
    import Toybox.WatchUi;
    import Toybox.Sensor;
    
    class valueView extends WatchUi.SimpleDataField {
    
        function initialize() {
            SimpleDataField.initialize();
            label = "Water depth M";
        }
       function compute(info as Activity.Info) as Numeric or Duration or String or Null {
            var x=((info.ambientPressure/100)+28.1);//conversion Pa to Mb + error
            var y=0;
        if(x!=null) {
                y = -((x - 1013.25)/100.7); //1013 average sea level pressure Pr, h=(P-Pr)/((sea water 1027kg*9.81m/s sq)/10') data displayed in - neg for depth      
        }
           return y ;
            }   
       }

  • Hello all 

    Iv noticed custom data fields don't get logged say like HR, anyway to log custom data fields for viewing in Garmin connects app ? 

  • Use fit contrib for user data and define how it's displayed in Garmin Connect using fitcontib resources

  • Hi Jim, thanks for your reply. would you have any literature on how to use fit contrib ? 

    Thanks 

  • Thanks, would you have a working example of the code being implemented?