1. Toybox.Activity.Info
   URL: https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity/Info.html
   Toybox.Activity.Info

# Class: Toybox.Activity.Info

Inherits: Toybox.Lang.Object

show all

## Overview

The Info class contains information about the current activity.

This information can be retrieved with the getActivityInfo() method. Fields in this class may return`null` so should be checked for`null` values prior to use.

## Instance Member Summary collapse

altitude as Lang.Float or Null

The altitude above mean sea level in meters (m).

ambientPressure as Lang.Float or Null

The ambient pressure in Pascals (Pa).

averageCadence as Lang.Number or Null

The average cadence during the current activity in revolutions per minute (rpm).

averageDistance as Lang.Float or Null

The average swim stroke distance from the previous interval in meters (m).

averageHeartRate as Lang.Number or Null

The average heart rate during the current activity in beats per minute (bpm).

averagePower as Lang.Number or Null

The average power during the current activity in Watts (W).

averageSpeed as Lang.Float or Null

The average speed during the current activity in meters per second (mps).

bearing as Lang.Float or Null

The current bearing in radians.

bearingFromStart as Lang.Float or Null

The bearing from the starting location to the destination in radians.

calories as Lang.Number or Null

The calories burned throughout the current activity in kilocalories (kcal).

currentCadence as Lang.Number or Null

The current cadence in revolutions per minute (rpm).

currentHeading as Lang.Float or Null

The true north referenced heading in radians.

currentHeartRate as Lang.Number or Null

The current heart rate in beats per minute (bpm).

currentLocation as Position.Location or Null

The current location.

currentLocationAccuracy as Position.Quality or Null

The current GPS accuracy.

currentOxygenSaturation as Lang.Number or Null

The current oxygen saturation in percent (%).

currentPower as Lang.Number or Null

The current power in Watts (W).

currentSpeed as Lang.Float or Null

The current speed in meters per second (mps).

distanceToDestination as Lang.Float or Null

The distance to the destination in meters (m).

distanceToNextPoint as Lang.Float or Null

The distance to the next point in meters (m).

elapsedDistance as Lang.Float or Null

The elapsed distance of the current activity in meters (m).

elapsedTime as Lang.Number or Null

Elapsed time of the current activity in milliseconds (ms).

elevationAtDestination as Lang.Number or Null

The elevation at the destination in meters (m).

elevationAtNextPoint as Lang.Float or Null

The elevation at the next point in meters (m).

energyExpenditure as Lang.Float or Null

The current energy expenditure in kilocalories per minute (kcals/min).

frontDerailleurIndex as Lang.Number or Null

The current front bicycle derailleur index.

frontDerailleurMax as Lang.Number or Null

The front bicycle derailleur maximum index.

frontDerailleurSize as Lang.Number or Null

The front bicycle derailleur gear size in number of teeth.

maxCadence as Lang.Number or Null

The maximum cadence recorded during the current activity in revolutions per minute (rpm).

maxHeartRate as Lang.Number or Null

The maximum heart rate recorded during the current activity in beats per minute (bpm).

maxPower as Lang.Number or Null

The maximum power recorded during the current activity in Watts (W).

maxSpeed as Lang.Float or Null

The maximum speed recorded during the current activity in meters per second (mps).

meanSeaLevelPressure as Lang.Float or Null

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

nameOfDestination as Lang.String or Null

The name of the destination.

nameOfNextPoint as Lang.String or Null

The name of the next point.

offCourseDistance as Lang.Float or Null

The distance to the nearest point on the current course in meters (m).

rawAmbientPressure as Lang.Float or Null

The raw ambient pressure in Pascals (Pa).

rearDerailleurIndex as Lang.Number or Null

The current rear bicycle derailleur index.

rearDerailleurMax as Lang.Number or Null

The rear bicycle derailleur maximum index.

rearDerailleurSize as Lang.Number or Null

The rear bicycle derailleur gear size in number of teeth.

startLocation as Position.Location or Null

The starting location of the current activity.

startTime as Time.Moment or Null

The starting time of the current activity.

swimStrokeType as Activity.SwimStrokeType or Null

The swim stroke type from the previous length.

swimSwolf as Lang.Number or Null

The SWOLF score from the previous length.

timerState as Activity.TimerState or Null

The recording timer state.

timerTime as Lang.Number or Null

The current Timer value in milliseconds (ms).

totalAscent as Lang.Number or Null

The total ascent during the current activity in meters (m).

totalDescent as Lang.Number or Null

The total descent during the current activity in meters (m).

track as Lang.Float or Null

The current track in radians.

trainingEffect as Lang.Float or Null

The Training Effect score of the current activity.

## Instance Attribute Details

### var altitude as Lang.Float or Null

The altitude above mean sea level in meters (m).

Elevation is derived from the most accurate source: Barometer or GPS

### var ambientPressure as Lang.Float or Null

The ambient pressure in Pascals (Pa).

This returns ambient (local) barometric pressure as measured by the pressure sensor. The data is smoothed by a two-stage filter to reduce noise and instantaneous variation.

### var averageCadence as Lang.Number or Null

The average cadence during the current activity in revolutions per minute (rpm).

### var averageDistance as Lang.Float or Null

The average swim stroke distance from the previous interval in meters (m).

### var averageHeartRate as Lang.Number or Null

The average heart rate during the current activity in beats per minute (bpm).

### var averagePower as Lang.Number or Null

The average power during the current activity in Watts (W).

### var averageSpeed as Lang.Float or Null

The average speed during the current activity in meters per second (mps).

The average is computed as the elapsed 3-D accumulated distance divided by the elapsed time.

### var bearing as Lang.Float or Null

The current bearing in radians.

Bearing is the direction from your current location or position to the destination of navigation, dependent on your current location.

### var bearingFromStart as Lang.Float or Null

The bearing from the starting location to the destination in radians.

Bearing from start is the direction of desired track from the start of navigation to the destination in radians. This is only dependent on your location when a course is set, and it is not dependent on where you may have moved to during an activity

### var calories as Lang.Number or Null

The calories burned throughout the current activity in kilocalories (kcal).

### var currentCadence as Lang.Number or Null

The current cadence in revolutions per minute (rpm).

### var currentHeading as Lang.Float or Null

The true north referenced heading in radians.

This provides compass orientation if it is supported by the device.

### var currentHeartRate as Lang.Number or Null

The current heart rate in beats per minute (bpm).

### var currentLocation as Position.Location or Null

The current location.

This member will always provide a`null` value unless the Positioning Permission is enabled.

### var currentLocationAccuracy as Position.Quality or Null

The current GPS accuracy.

GPS accuracy values range from 0-4. A value of 0 indicates an accuracy value is not available, while a value of 4 indicates a good GPS fix.

### var currentOxygenSaturation as Lang.Number or Null

The current oxygen saturation in percent (%)

### var currentPower as Lang.Number or Null

The current power in Watts (W).

### var currentSpeed as Lang.Float or Null

The current speed in meters per second (mps).

### var distanceToDestination as Lang.Float or Null

The distance to the destination in meters (m).

### var distanceToNextPoint as Lang.Float or Null

The distance to the next point in meters (m).

### var elapsedDistance as Lang.Float or Null

The elapsed distance of the current activity in meters (m).

### var elapsedTime as Lang.Number or Null

Elapsed time of the current activity in milliseconds (ms).

### var elevationAtDestination as Lang.Number or Null

The elevation at the destination in meters (m).

### var elevationAtNextPoint as Lang.Float or Null

The elevation at the next point in meters (m).

### var energyExpenditure as Lang.Float or Null

The current energy expenditure in kilocalories per minute (kcals/min).

Energy expenditure is a metric developed by FirstBeat that provides an estimation of the calorie burn rate calculated from heart rate data.

### var frontDerailleurIndex as Lang.Number or Null

The current front bicycle derailleur index.

Index values range from from 1 to the frontDerailleurMax.

### var frontDerailleurMax as Lang.Number or Null

The front bicycle derailleur maximum index.

### var frontDerailleurSize as Lang.Number or Null

The front bicycle derailleur gear size in number of teeth.

### var maxCadence as Lang.Number or Null

The maximum cadence recorded during the current activity in revolutions per minute (rpm).

### var maxHeartRate as Lang.Number or Null

The maximum heart rate recorded during the current activity in beats per minute (bpm).

### var maxPower as Lang.Number or Null

The maximum power recorded during the current activity in Watts (W).

### var maxSpeed as Lang.Float or Null

The maximum speed recorded during the current activity in meters per second (mps).

### 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.

### var nameOfDestination as Lang.String or Null

The name of the destination.

### var nameOfNextPoint as Lang.String or Null

The name of the next point.

### var offCourseDistance as Lang.Float or Null

The distance to the nearest point on the current course in meters (m).

### var rawAmbientPressure as Lang.Float or Null

The raw ambient pressure in Pascals (Pa).

This returns ambient (local) barometric pressure as measured by the internal pressure sensor. The data is the temperature compensated information read directly from the internal sensor.

### var rearDerailleurIndex as Lang.Number or Null

The current rear bicycle derailleur index.

Index values range from from 1 to the rearDerailleurMax.

### var rearDerailleurMax as Lang.Number or Null

The rear bicycle derailleur maximum index.

### var rearDerailleurSize as Lang.Number or Null

The rear bicycle derailleur gear size in number of teeth.

### var startLocation as Position.Location or Null

The starting location of the current activity.

This member will always provide a`null` value unless the Positioning Permission is enabled.

### var startTime as Time.Moment or Null

The starting time of the current activity.

### var swimStrokeType as Activity.SwimStrokeType or Null

The swim stroke type from the previous length.

Swim stroke type values range from 0-6. Each Number value represents a different swim stroke type (e.g. freestyle, backstroke, etc.).

### var swimSwolf as Lang.Number or Null

The SWOLF score from the previous length.

SWOLF is an abbreviation for Swim-Golf, a measure of swimming efficiency. The score is obtained by adding the strokes per length to the total time of the length. For example, if it takes ten strokes and thirty seconds to swim a pool length, the SWOLF score is 40. Just like golf, a lower SWOLF score is better.

### var timerState as Activity.TimerState or Null

The recording timer state.

The timer state ranges from 0-3. A value of 0 indicates that the timer is off and there is no active recording, while a value of 3 indicates timer is on and there is an active recording.

### var timerTime as Lang.Number or Null

The current Timer value in milliseconds (ms).

### var totalAscent as Lang.Number or Null

The total ascent during the current activity in meters (m).

### var totalDescent as Lang.Number or Null

The total descent during the current activity in meters (m).

### var track as Lang.Float or Null

The current track in radians.

Track is the direction of travel in radians based on GPS movement. If supported by the device, this provides compass orientation when stopped.

### var trainingEffect as Lang.Float or Null

The Training Effect score of the current activity.

Training Effect is a score developed by FirstBeat, which indicates an activity's level of effect on aerobic fitness. Scores range from 1.0 (easy) to 5.0 (overreaching).

---

Generated Jun 8, 2026, 3:42:15 PM

2. Activity.getActivityInfo() on FR45 mostly not working as expected - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/281696/activity-getactivityinfo-on-fr45-mostly-not-working-as-expected
   Activity.getActivityInfo() on FR45 mostly not working as expected - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- Replies 15 replies
- Subscribers 19 subscribers
- Views 3931 views
- Users 0 members are here

Options

Related

# Activity.getActivityInfo() on FR45 mostly not working as expected

I tested Activity.getActivityInfo() in the simulator and on my fr45.

It appears that only altitude and currentLocationAccuracy are recognized by my device.

The simulator guesses that Calories works but not LocationAccuracy.

//Capital letters means it's not null. Probably a bad way to check, but it's simple sanity check.

var info = Activity.getActivityInfo();

// checks += info.ambientPressure ? "P" : "p"; //error API Level 2.4.0

checks += info.altitude ? "A" : "a";

checks += info.averageHeartRate ? "A" : "a";

// checks += info.averagePower ? "P" : "p"; // Error: Symbol Not Found Error API Level 1.0.0

checks += info.calories ? "C" : "c";

checks += info.currentHeading ? "C" : "c";

checks += info.currentHeartRate ? "H" : "h";

checks += info.currentLocationAccuracy ? "9" : "l";

// checks += info.currentOxygenSaturation ? "O" : "o"; // API Level 3.2.0

// checks += info.currentPower ? "P" : "p"; // Error: Symbol Not Found Error, API Level 1.0.0

checks += info.elapsedDistance ? "D" : "d";

// checks += info.energyExpenditure ? "E" : "e"; // Error: Symbol Not Found Error, API Level 1.2.0

View.findDrawableById("Readings").setText( checks );

Using 4.0.7 on Linux to build and 4.1.0B1 to simulate

Using the following to compile and run: monkeyc -d fr45 -f monkey.jungle -o dw.prg -y ../devkey/developer_key && monkeydo dw.prg fr45

Using the following to build with vscode 1.63.2: ctrl + shift + P

On the device I get: Aacch9d

In the simulator I get: AaCchld

I tried going to the widgets and into activities to see if any of those might activate any of these readings.

On a side note, how do I iterate through this object?

In python I'd do something like this: [ if info[i] then 1 else 0 for i in info ]

Pretty printing an object and seeing the properties would be nice too (instead of "Obj: 177")

- Sign in to reply
- Cancel

## Top Replies

Is power device power or human power (perhaps some calculation based off of body weight and temperature difference)?

It's power from a paired bike power sensor. Note that the Stryd running…

I still haven't figured out sideloads.

Use "Monkey C: Build for Device" in the VS Code command palette, connect the device via USB and copy the PRG file to \GARMIN\APPS on the device…

- It would be far easier to trade in your fr45 for an fr55. The 55 is ciq 3.x, and allows all app types.

## All Replies

// checks += info.currentPower ? "P" : "p"; // Error: Symbol Not Found Error, API Level 1.0.0

Power isn't supported by FR45 -- it's only supported by "multisport"/outdoor watches (FR7xx, FR9xx, Fenix) and Edge devices, so it's totally expected that trying to access power on an FR45 would return symbol not found.

//Capital letters means it's not null. Probably a bad way to check, but it's simple sanity check.

checks += info.calories ? "C" : "c";

This doesn't check whether info.calories is non-null or null, it's checks whether it's "truthy" or not. Meaning that either 0 or null will cause "c" to be printed out for the 3rd character of your output string. If you really want to see what's non-null, you should check for that explicitly, perhaps using a helper function to make it easier to read/maintain.

On a side note, how do I iterate through this object?

In python I'd do something like this: [ if info[i] then 1 else 0 for i in info ]

Pretty printing an object and seeing the properties would be nice too (instead of "Obj: 177")

Yeah, sadly you can't do that in Monkey C.

Many of these things that seem like they should work, don't.

I tried going to the widgets and into activities to see if any of those might activate any of these readings.

Well, anything that returns Symbol Not Found is definitely not going to work (for that device) no matter what you do. Some things which are currently zero or null in your testing are probably that way because you haven't started an activity.

You didn't mention what kind of app this is -- a device app, data field, widget or watchface? This also affects your ability to test this stuff in the sim. If it's a data field, for example, then you can simulate an activity/FIT data and see some of this data.

Same goes for testing it on the real device: If you build a data field, add it to an activity, wear the watch outdoors, get a GPS fix, and start the activity, you should see pretty much all the data that's available, such as (average) heart rate.

If it's a device app, then you'll have to explicitly enable GPS in your code (see Position.enableLocationEvents()). As far as something like HR goes, IIRC, wrist HR is automatically enabled, but not external HR sensors.

As a side note, last time I checked, elapsed distance is null (and not 0) when you haven't started an activity yet. Perhaps this is to give the dev a way to distinguish between an activity which hasn't started, and an activity which has started but hasn't accumulated any distance yet (although there's other ways to do this.)

Only a couple of things in Activity.Info can be used in a watch face, and even those can vary by specific device (not on a Fenix5x for example)

currentHeartRate and currentLocation are the two that are commonly used, and for location, you need to have the positioning permission set.

Many of the things you are using aren't available unless an activity is being record, and things like pressure are only there on devices with a baro altimeter (the fr45 doesn't have one)

Hey FlowState (cool username btw), thanks for those insights, I mistakenly made a connection to earlier API levels to all devices and didn't check the individual ones. Is power device power or human power (perhaps some calculation based off of body weight and temperature difference)?

You're right about truthy (wasn't sure about the terminology in Monkey C), but figured it'd update after an activity. However, apparently some of these like currentHeartRate are supposed to be accessible outside of an activity? My impression from reading the documentation was that none of these were usable without an activity currently being recorded and that if you were recording an activity you wouldn't be in the watch face mode so it was pointless to try to access it. jim_m_58 mentioned that currentHeartRate still works outside of an activity, so this was me hoping I'd have access to other stuff too. For good measure, I also tried checks += null != info.whatever ? ... and didn't get a change in the output.

It's a watchface app (the only one that fr45 has access to according to https://developer.garmin.com/connect-iq/compatible-devices/) and I didn't need to enable Position.enableLocationEvents() but it might have generated some code that did this.

Thanks for mentioning the bit about elapsedDistance.

As for the python list comprehension is there no way to iterate through the object properties? Using a more traditional for loop would be fine.

Looks like I needed the fallback with ActivityMonitor.getHeartRateHistory(1, true).next().heartRate (as jim_m_58 shared here in a comment https://forums.garmin.com/developer/connect-iq/f/discussion/281641/fr45-preinstalled-watch-face-code/1352663#1352663)

One thing to note is currentLocation won't actually be the current one, but it's the last location from when an activity with GPS was recorded, but is still useful to show things like sunrise/sunset.

Thanks for helping to clear that up and specifically mentioning that the fr45 doesn't have a barometer. That's an important distinction for currentLocation, thanks for that too. And, for helping me get the heartrate recognized on the device (via the other thread). I think some of this information would be stuff I could get via the phone connection (perhaps with ANT or something else)? I see that there's a preinstalled weather widget that works, but weather isn't available in the API until 3.2.0. That has me a bit confused.

Is power device power or human power (perhaps some calculation based off of body weight and temperature difference)?

It's power from a paired bike power sensor. Note that the Stryd running pod also uses the bike power ANT+ protocol, so if it's paired natively, you can get power from Stryd too. (The Garmin RD pod and HRM-RUN chest strap do not use this protocol).

Note that all devices which support pairing a bike power sensor natively also support power in activity info. All of the devices which don't have power in activity info also lack native support for pairing a bike power sensor.

You're right about truthy (wasn't sure about the terminology in Monkey C),

Yeah, I don't think that's Monkey C terminology actually, but it's the most appropriate word I can think of for "a value that is considered true in a boolean context." I stole it from JavaScript, of course. But even C, one could say that any non-zero value is truthy. (And of course in C, NULL is 0.)

Note that Monkey C is not exactly like js here.

if (a)

will run without error when a is null. (null is falsey).

But

if (a && b)

will crash with a run-time type error if a is null. There's just some little inconsistencies in the language implementation (imo).

(The above example is trivial to rewrite properly, but you lose a tiny bit of memory for the extra code, which can make a difference for apps which have tight memory limits, like data fields on a non-music device.)

It's a watchface app (the only one that fr45 has access to according to https://developer.garmin.com/connect-iq/compatible-devices/)

Oh right. my bad.

and I didn't need to enable Position.enableLocationEvents() but it might have generated some code that did this.

Nah, that would only apply to device apps and widgets.

As for the python list comprehension is there no way to iterate through the object properties?

I'm fairly sure there's no way to iterate through object properties in Monkey C, sadly, although I'd love to be proven wrong on this. You can't even convert a symbol to it's human-readable source code label at runtime, IIRC, so even if you could iterate through object properties, you wouldn't be able to get meaningful names for the "keys". (Object methods and member variables are all represented by symbols, so you could put a bunch of symbols in an array and iterate through that. But of course you would have to know the symbols in advance, at compile-time.)

I see that there's a preinstalled weather widget that works, but weather isn't available in the API until 3.2.0. That has me a bit confused.

Native apps don't have the same constraints as CIQ apps. (You'll see this come up many times if you dig into the CIQ ecosystem.)

Thanks for the elaborations, clarifications, explanations, and the surprising if(truthy) example (normally null is falsey). I think since things compile to byte code, someone might be able to make an app that's not a watchface by writing in bytecode directly. It'd be in the reverse engineering territory, but it seems plausible even if I really would not want to bother doing that.

Thanks for the elaborations, clarifications, explanations, and the surprising if(truthy) example (normally null is falsey).

Sorry, to be clear, null is falsey. I just mean that if (a) works as expected, without crashing, when a is null. if (a && b) will crash with a run-time type error when a is null, because null && x is not allowed in Monkey C.

I think since things compile to byte code, someone might be able to make an app that's not a watchface by writing in bytecode directly. I

I don't think so, as you'd have to upload the app to the store, and the store would block you from uploading app types which are not allowed.

Furthermore, even for sideloads, the FR45 probably doesn't even have the on-device infrastructure to support CIQ widgets, data fields and device apps. (That's extra code on the firmware side which doesn't seem like it would need to be included if it would never be used.)

It would be far easier to trade in your fr45 for an fr55. The 55 is ciq 3.x, and allows all app types.

3. How to simply read pressure info? - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/245448/how-to-simply-read-pressure-info
   How to simply read pressure info? - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- State Verified Answer
- Replies 24 replies
- Subscribers 18 subscribers
- Views 6795 views
- Users 0 members are here

Options

Related

# How to simply read pressure info?

Hello, may I please ask for help?

at beginning of code I set

using Toybox.Sensor;

and then in function onUpdate(dc) I am trying to read pressure with

var status = Sensor.getInfo();

var pres = status.pressure;

But at runtime I get error

Error: Permission RequiredDetails: Module 'Toybox.Sensor' not available to 'Watch Face'

What can I do please?

- Sign in to reply
- Cancel

## Top Replies

- Set the permission for that. You can do that in a watchface. In eclipse, click the manifest file and there is a tab for permissions.

## All Replies

Just that. You can't use Sensor in a watch face itself. You can use it in a watch face's background service.

Or you can get the pressure by way of SensorHistory.getPressureHistory() and look at the newest sample or Activity.getActivityInfo().ambientPressure.

Thanks for quick answer. I am trying to get pressure with Activity.Info.meanSeaLevelPressure;. However, it returns null. I suspect that GPS needs to function because of altitude. I started activity on watch, waited to get GPS lock but it still displays null.

I would prefer to get pressure from garmin weather info, is that possible?

Thanks, Jan

The garmin weather info doesn't include pressure.

When you tested meanSeaLevelPressure, was that on a watch or in the sim? What device? It's got to be one with a baro altimeter.

Tactix Delta, it does have barometer. I did not test it for long time and not outdoors, I will try later. Thank you very much for answers.

I tried var p = SensorHistory.getPressureHistory({});

but get runtime error:

Error: Permission RequiredDetails: Permission for module 'Toybox.SensorHistory' required

I tried var p = SensorHistory.getPressureHistory({});

but get runtime error:

Error: Permission RequiredDetails: Permission for module 'Toybox.SensorHistory' required

Set the permission for that. You can do that in a watchface. In eclipse, click the manifest file and there is a tab for permissions.

Thanks very much, it worked. My watch is now showing pressure taken from history :-)

We are using Activity.getActivityInfo().ambientPressure, meanSeaLevelPressure and rawAmbientPressure , and none of them seem to match the value of the pressure at GARMIN app, or the readings other watchfaces do. What are we missing??

Many things just use SensorHistory.getPressureHistory() and the newest sample.

4. Ambient pressure and pressure history don't match - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/244746/ambient-pressure-and-pressure-history-don-t-match
   Ambient pressure and pressure history don't match - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- Replies 24 replies
- Subscribers 18 subscribers
- Views 5648 views
- Users 0 members are here

Options

Related

# Ambient pressure and pressure history don't match

Hey all, does anyone know what pressure the pressure history is storing? I have tested with putting both on screen and my ambient pressure is always higher than my max pressure history (over last 30 mins) so what is this doing?

If I look at my watch now it shows PH getMax to be 101833 and my AP now to be 102996. The PH never been above 101... if I put it in water (20cm) the AP goes up to 104888 which shows AP sensor is moving but PH never changes or goes near it.

Any insights would be great as I am trying to see historical pressure history to make a "guess" on no fly time for diving.

Many thanks,

Ben

- Sign in to reply
- Cancel

I'm not sure how SH.getPressureHistory deals with being under water. If I recall it's MSL pressure. Also, how often it's saved likely varies by device, where you can find the interval by comparing "when" in two adjacent samples.

And getting Sensor.Info.pressure can vary from what you see in Activity.Info.ambientPressure/Activity.Info.rawAmbientPressure

Ahh fiddle sticks... MSL pressure is of no use to me and that explains why it doesn't seem to change in the history even when submerged in water for 10 minutes. Must also be adjusting for depth of water (as this is the MK2 so has a depth sensor but cannot access it through CIQ I don't think?)

Basically, doesn't look like I can do what I want so will have to use the standard Garmin faces when diving and custom one when not :(

Thanks for the info Jim, appreciate it!

Actually stupid question, could I not just get raw and store date and time in a variable and do it that way..? The code doesn't reset each refresh does it? That would work I think :)

Actually that won't work as the WF has to be active to measure anything which it won't during a dive.

Also, Jim, does the memory/variables reset when you navigate away from the WF and back to it do you know? Thanks again.

Yes, you can build your own list of data and time. You might be able to do it in the main app, but you can also use a background service to take a reading every X minutes. In either case, you'll want to store the data using Application.Storage. You have to handle missing data.

I just saw your new post, but with a background process you can probably run the background while doing a dive.

Interesting, will look into that. Don't want to lag or run battery down for this so will see what performance is like on it :)

Thanks again for the info! :)

Here's a widget I did that does a graph of temperature using a background process. In general, the way it works is I save up to 96 samples with a time stamp. For a 4hr graph, the background runs every 4 minutes, but for a 48hr graph, every 30 minutes. Try it on your next dive. For missing readings, you'll see a pink mark under the graph.

The background in this is actually pretty minor, with the heavy lifting done in the widget itself.

Great, thanks. Will have a look at running background processes and see if that can work. Out of curiosity, why wouldn't you use temperature history for this or was it more of an experiment to see if it worked? (also this is a default widget isn't it or did you make it before that became standard?)

Thanks again Jim, you seem to be the fountain of knowledge on these forums because the Garmin library docs are terrible! :) hehe

SH.getTemperatureHistory only provides about 4hrs of data, and I wanted to allow for a couple days of data, so I did my own caching. And this doesn't require the widget itself to be run on a regular basis.

Ah of course, mine does say last 4 hours to be fair. Cool, will give this a go :)

Found a blog post you referenced 3 years ago but it is broken :( I cannot find any examples but is it a case of using a registerForTemporalEvent and setting it every say 10 minutes and then adding data to the Application.Storage? That how this would work? Sorry for all the Q's but I work better off examples and cannot find any I understand and this monkey C is pretty new to me

Thanks again

5. Toybox.Activity.Info vs. on Device Pressure - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/262285/toybox-activity-info-vs-on-device-pressure
   Toybox.Activity.Info vs. on Device Pressure - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- State Verified Answer
- Replies 3 replies
- Subscribers 17 subscribers
- Views 999 views
- Users 0 members are here

Options

Related

# Toybox.Activity.Info vs. on Device Pressure

Apologies if this is a common topic - couldn't find anything recent.

I've implemented pressure readings on my watch faces, but I am running into something I can't quite figure out. None of the available pressures in CIQ (ambientPressure, rawAmbientPressure, nor meanSeaLevelPressure) from Toybox.Activity.Info match the on-device pressure widget.

Does anyone know why this may be the case, and if so, how I can match the pressure readings up? Am I using the wrong variable, or is there some other issue? Some users are confused, and I am as well!

- Sign in to reply
- Cancel

## Top Replies

- Have you looked at SensorHistory.getPressureHistory(). The newest sample? You can also look in Sensor.Info, but with a watch face you can only do that in a background service.

## All Replies

Have you looked at SensorHistory.getPressureHistory(). The newest sample? You can also look in Sensor.Info, but with a watch face you can only do that in a background service.

Good idea - I have not. I'll give that a try tonight and see if it gives results more in line with the widget!

Yep, looks like that pulls the expected data. Thanks!

6. Toybox.Sensor.Info
   URL: https://developer.garmin.com/connect-iq/api-docs/Toybox/Sensor/Info.html
   Toybox.Sensor.Info

# Class: Toybox.Sensor.Info

Inherits: Toybox.Lang.Object

Toybox.Lang.Object

Toybox.Sensor.Info

show all

## Overview

The Sensor.Info class contains all of the information provided by enabled sensors.

Sensor.Info can be retrieved on every call of onUpdate() or it can be obtained on demand. Fields in this class may return`null` so should be checked for`null` values prior to use.

## Instance Member Summary collapse

accel as Lang.Array< Lang.Number> or Null

The accelerometer reading of the x, y, and z axes as an Array of Number values in millig-units.

altitude as Lang.Float or Null

The altitude above mean sea level in meters (m).

cadence as Lang.Number or Null

The cadence in revolutions per minute (rpm).

heading as Lang.Float or Null

The true north referenced heading in radians.

heartRate as Lang.Number or Null

The heart rate in beats per minute (bpm).

mag as Lang.Array< Lang.Number> or Null

The magnetometer reading of the x, y, and z axes as an Array of Number values in milliGauss (mG).

oxygenSaturation as Lang.Number or Null

The current oxygen saturation in percent (%).

power as Lang.Number or Null

The power in Watts (W).

pressure as Lang.Float or Null

The barometric pressure in Pascals (Pa).

speed as Lang.Float or Null

The speed in meters per second (m/s).

temperature as Lang.Float or Null

The temperature in degrees Celsius (C).

## Instance Attribute Details

### var accel as Lang.Array<Lang.Number> or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Array.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The accelerometer reading of the x, y, and z axes as an Array of Number values in millig-units.

### var altitude as Lang.Float or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Float.html

The altitude above mean sea level in meters (m).

Elevation is derived from the most accurate source: Barometer or GPS in order of descending accuracy. If no GPS is present, then barometer readings will be used.

### var cadence as Lang.Number or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The cadence in revolutions per minute (rpm).

Cadence is derived from (in order of priority):

Bike sensors (cadence or speed must be enabled)

Advanced running dynamics sensors (e.g. heart strap with running dynamics enabled)

Foot pod

Watch-based cadence calculations

### var heading as Lang.Float or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Float.html

The true north referenced heading in radians.

This provides compass orientation if it is supported by the device.

### var heartRate as Lang.Number or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The heart rate in beats per minute (bpm).

### var mag as Lang.Array<Lang.Number> or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Array.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The magnetometer reading of the x, y, and z axes as an Array of Number values in milliGauss (mG).

### var oxygenSaturation as Lang.Number or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The current oxygen saturation in percent (%)

### var power as Lang.Number or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Number.html

The power in Watts (W).

### var pressure as Lang.Float or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Float.html

The 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.

### var speed as Lang.Float or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Float.html

The speed in meters per second (m/s).

### var temperature as Lang.Float or Null

https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Float.html

The temperature in degrees Celsius (C).

---

Generated Jun 8, 2026, 3:42:17 PM

7. Retrieve ambient pressure in foreground - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/288741/retrieve-ambient-pressure-in-foreground
   Retrieve ambient pressure in foreground - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- Replies 11 replies
- Subscribers 18 subscribers
- Views 1953 views
- Users 0 members are here

Options

Related

# Retrieve ambient pressure in foreground

Toybox.Sensor.getInfo().ambientPressure needs the permission Toybox.Sensor - I don't have added this permission yet because until now I used the pressure history.

I realised that ambientPressure is the value I want to display and not the one from the history and want to change this now.

1) it seems like ambientPressure value can't be retrieved from history, correct?

2) I realised that Toybox.Sensor also needs the background permission, does this mean I can only read the ambientPressure in the background?

Actually I don't want to add 2 permissions for this single data value to my watchface, is there no alternative way to get the current pressure (or last in one from history)?

- Sign in to reply
- Cancel

With a watch face, you can only access Sensor data in a background service.

Try Activity.getActivityInfo().ambientPressure in the foreground

Be sure to handle devices without a baro altimeter

In the sim I can access ambientPressure without an exception but it returns null (without adding the necessary permissions though)... But you say, the foreground access won't work on a real device anyway, that's the important information for me. Btw, adding background + sensor permission approx. halves the available memory for a watchface (ERROR: PRG generated exceeds the memory limit of 'background' applications for device id 'fenix6xpro': 63883 bytes) - is this something I have to accept or can I circumvent this side effect?

Can't I alternatively convert pressure to ambientPressure with the history data?

In the sim, are you simulating data? Try Activity.Info on a real device with a baro if you have doubts.

Once you add background permission, you want to make sure you use the (:background) annotation where needed, otherwise it will try to load the entire WF when the background runs, inclusing when onAppInstall() or onAppUpdate() are called.

Now that I simulate data it shows a value - thanks. Even without adding additional permissions.

Oh, now I remember that in need to add :background annotations where needed to avoid my whole WF is running in the background - thanks.

So actually you say something different than I though - that real devices with baro allow to access Activity.getActivityInfo().ambientPressure in the foreground? So I just have to add the permissions, make sure my WF is running in foreground and it will work on a real device? Or will it work without the additional permissions in the foreground on a real device (as this is what I see in the sim)?

hi, no permission is need for Activity.getActivityInfo().ambientPressure

when Jim said "Be sure to handle devices without a baro altimeter" I think he means to check if the device has a Baro with

if(Activity.getActivityInfo() has :ambientPressure){...}

if you use this method, you don't need :Background annotation or permission.

Thanks, that answers all open questions. The unsure phrase for me was "you can only access Sensor data in a background service"

yes the module Sensor. but Activity is available from foreground.

Don't forget to check null statment

thanks for clarifying that. Btw, isn't the null check enough for class variables? I actually though the :has must only be used for functions...

hi, no it is not enough, if you try for exemple Activity.getActivityInfo().ambientPressure on a F45, it will crash since FR45 does not have ABC sensor.

see the API doc, you have lots of exemple of :has

You want to do the has check too. Devices like the fr45, fr55, fr245 and venu sq don't have a baro altimeter.

8. Ambient Pressure and Mean Seal Level Pressure Mismatch - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/324960/ambient-pressure-and-mean-seal-level-pressure-mismatch
   Ambient Pressure and Mean Seal Level Pressure Mismatch - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- Replies 4 replies
- Subscribers 19 subscribers
- Views 1459 views
- Users 0 members are here

Options

- Share
- More
- Cancel

Related

# Ambient Pressure and Mean Seal Level Pressure Mismatch

I've been seeing a discrepancy between the watch-calculated mean sea level pressure and true calculations based on the watch-observed ambient pressure. Based on the actual mean sea level pressure in the area, the value returned from meanSeaLevelPressure appears inaccurate. Here are more specific details from the simulator using simulated data:

- Activity.Info.meanSeaLevelPressure returns a value of 102154.98 Pa (This is the seemingly incorrect value, should be 101045 Pa).
- Activity.Info.ambientPressure returns a value of 87026.59 Pa
- Activity.Info.altitude returns a value of 1242.70 m
- SensorHistory.getTemperatureHistory (the last value in the iteration) returns a temperature of 25.5 C

Using that ambient pressure (87026 Pa) and altitude (1242 m), the mean sea level pressure should be 101045 Pa1, or 99957 Pa2 with a Temperature correction. The returned meanSeaLevelPressure is substantially off using the Garmin API. There should be only a couple areas where that error could occur

1. The altitude used in meanSeaLevelPressure is substantially (roughly 100m) different than that of Activity.Info.altitude .
2. The temperature correction used in meanSeaLevelPressure is different than returned by SensorHistory.getTemperatureHistory , however the documentation of meanSeaLevelPressure only suggests it is corrected for altitude
3. The formulas used to calculate meanSeaLevelPressure in the API have an error.

Does anyone have any more insight into the specifics of the calculations and data Activity.Info.meanSeaLevelPressure utilizes? I'm consistently seeing errors in my watch face from actual measurements to the displayed data using the API data. Is there anything I may be missing?

---

References for calculations:

1) Elevation, Station (QFE) and Sea Level (QNH) Pressure Calculator (sensorsone.com)

2) Mean sea level pressure calculator (converter) (wind101.net)

- Sign in to reply
- Cancel

This is something you really want to look at on a real device and not the sim. To compute MSL pressure it needs ambient presume and elevation, and based on device there are different ways to calibrate the altitude/elevation. You can enter a specific value, use GPS, or DEM.

And then there's the case where you can be in the same location, but the weather, therefore ambient pressure, changes over time

And then even on a real device, getXyzHistory isn't real time, but is only saved every few minutes (you can tell how often by using the "when" values of two adjacent samples. In the sim some of this data is "canned" and doesn't change over time

Here for example are graphs of getPressureHistory and getTemperatureHistory in the sim. Both are canned and never change:

Thats a great thought --- I'll work on building a quick test app for my actual watch and update the post with that data if I'm seeing the same issue

Update with actual device data (still seeing the same issue as the sim, been monitoring the data for a couple hours):

Using the device measured ambient pressure and altitude, the non-temperature corrected value for MSL Pressure should be 98803.0 Pascals. Although that seems close, it is noticeably off when using inHg values for aviation.

The Garmin API meanSeaLevelPressure converts to an altimeter setting of 29.09 inHg. Using widely accepted calculations from the measured ambientPressure results in 98803.0 Pascals results in an altimeter setting of 29.18 inHg [actual value from weather service is 29.17 inHg].

What is interesting is the Garmin Barometer widget also shows the "correct" calculated value of 29.18 inHg. All this to say that the meanSeaLevelPressure value that is returned from the Garmin API neither matches the Garmin Barometer widget data, nor widely accepted calculation methods. Unless they're using some other method or pulling data from elsewhere, it seems like there's an error in the meanSeaLevelPressure calculations in Toybox.Activity.

I thought altitude was based on GPS reading .. my Mk1 is new to me and i am noticing that the altitude changes over a range of 10 m at my desk near the beach . currently 40m . assumed it was based on tide change (i keep the GPS on) .. . the pressure detection i assume is the same as the one used for depth on a dive which has to be a manometer of sorts (not calculated) & a critical datapoint.

- - Cancel
- - Up 0 Down
- Sign in to reply
- Cancel
- - Cancel
- - Up 0 Down
- Sign in to reply
- Cancel
- - meanSeaLevelPressure returns 98517.5 Pascals (still doesn't match typical calculations, should be 98803.0 Pascals)
- ambientPressure returns 88806.8 Pascals
- altitude returns 890.6 meters [actual altitude at location is 886.5 meters, this is pretty accurate]
- getTemperatureHistory returns 26.7 C
- - Cancel
- - Up 0 Down
- Sign in to reply
- Cancel
- - Cancel
- - Up 0 Down
- Sign in to reply
- Cancel

9. Widget: AirPressure - Connect IQ App Showcase - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/showcase/811/widget-airpressure/37431
   Widget: AirPressure - Connect IQ App Showcase - Connect IQ - Garmin Forums

- Cancel
- More
- German Forum
- Beta Program
- Developer
- Pilots
- Sports & Fitness
- Outdoor Recreation
- Apps & Software

- Users 0 members are here
- Views 3223 views
- Subscribers 4 subscribers
- Replies 17 replies

Options

- Cancel
- More
- Share

Related

# Widget: AirPressure

AirPressure WidgetSimple widget displaying the current atmospheric pressure as well as the barometric pressure (air pressure at sea level) and altitude. The Garmin barometer widget only displays the barometric pressure and there is currently no way to display the "raw" (unadjusted) atmospheric pressure on the Fenix 3 except by adding it as a datafield in an activity. This widget corrects this and displays the atmospheric pressure without having to start an activity.The widget is optimized for the Fenix 3. For a similar widget optimized for square watches (e.g. Epix, VivoFit etc.) please check out my AtmosphericPressure widget (https://apps.garmin.com/en-GB/apps/1183288c-4156-4dc2-83e4-dd555b9a22b1).**NOTE** I would have prefered to add a chart of pressure changes over the past 48 hours to the widget (useful for weather predictions) but for the time being Connect IQ API limitations prevent me from doing this (in order to update the chart at a fixed interval - say every 15 mins - I would need to be able to poll the current air pressure even when the widget is not active, something not currently possible with Connect IQ widgets).***CHANGE HISTORY***Changes made from version 1.0 to version 1.1:- added ability to display atmospheric pressure in either mmHg, inHg, milibars or hectopascals (press MENU while inside the widget to change measurement unit)- altitude is now displayed in either meters or feet depending on user settings

- Cancel
- Sign in to reply

Vivoactive HR Is it possible to get this widget for the Vivoactive HR? Thank!

Can this be updated to Fenix 5 series? Thanks,

I've used this on a Fenix3HR and it was excellent and v.accurate. Now I have upgraded to a Fenix5X and would love to have this on that watch. Please can you make this great widget compatible with the 5X as it would complete this watch.

I've created fenix 5 series and vaHR compatible version. https://apps.garmin.com/en-US/apps/00678298-6672-4228-9c82-c9aa00e43df0

> I've created fenix 5 series and vaHR compatible version. https://apps.garmin.com/en-US/apps/00678298-6672-4228-9c82-c9aa00e43df0

Hi,first, thanks for your widget.I have it now installed and looked at the values. Unfortunately, I have found deviations and would now like to ask how they can be explained.Fenix 5x data fields show baro 1018 and athmo 980.3.Widget shows baro 1023.1 and athmo 987.3Two other clocks also show athmo 980, which seems to be correct.How do you determine the atmospheric pressure?I did not find anything in the API documentation except barometric pressure with Sensor.Info.Thanks

Sensor.Info has MSL barometric pressure, available for all watches with CIQ 1.3 and higher. That means we can use formula for recalculation to ambient pressure.Altitude and temperature also required. You see what I mean? All you see on "old" device, that does not support CIQ 2.4, is recalculated from the values CIQ provided.These values are not ideal and not precise. All old watches use this calculation method (like f3 series).Thanks to CIQ Team, they listen us. They introduced SDK 2.4 and some watches like f5/vivoactive HR/va3, etc. will have support for this VM SDK. Activity.Info class now has new items (ambientPressure, rawAmbientPressure, meanSeaLevelPressure).These are available in widgets. Widget detects if it is possible to get "better" values, from SDK 2.4, and uses that data.Bad news, that values from SDK 2.4 are not the same that you see on data fields (sic! again!). Also they do not match with the values presents in service menu (turn device off, hold DOWN button, press and release POWER, 15 seconds wait and release DOWN, then appears menu with special tests and barometer's _real_ pressure).

Thanks for this widget. It is very close to what i was looking for: in fact i don’t care about real altitude , i am more interested in altitude-pressure starting from a standard 1013hPa at sea level. So i can record my bike performance during climbs knowing pressure and therefore oxygen level in the air. From your widget i will change altitude in altimeter calibration settings such that sea level pressure will indeed display 1013hPa.what i don’t actually understand is why there is a little drift such that i have to recalibrate again and again during day

10. Using the simulator to test Edge 1030 internal barometer readings? - Connect IQ App Development Discussion - Connect IQ - Garmin Forums
   URL: https://forums.garmin.com/developer/connect-iq/f/discussion/399918/using-the-simulator-to-test-edge-1030-internal-barometer-readings
   Using the simulator to test Edge 1030 internal barometer readings? - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- State Not Answered
- Replies 17 replies
- Subscribers 19 subscribers
- Views 2679 views
- Users 0 members are here

Options

Related

# Using the simulator to test Edge 1030 internal barometer readings?

I am attempting to use the Edge 1030 internal barometer pressure information within my Connect IQ app.

Connect IQ Device Simulator 7.3.0

I set up the test using:

---------------

import Toybox.Sensor;

private var _info = null;

private var _barometer = Lang.Float;

_info = Sensor.Info;

_barometer = _info.pressure;

System.println(_barometer) // this prints 'null'

------------

My problem starts when I want to test the _barometer object with an actual simulated value. I don't know how to do this.

Running: Simulation -> Activity Data

doesn't seem to supply the _barometer with an actual value.

If I change the above code to:

System.println(_barometer.toString()) // throws errors

Any direction on this would be appreciated. Relatively new to Monkey C and Connect IQ

- Sign in to reply
- Cancel

## Top Replies

I had tried creating an instance of the class

In general, the correct way to create an instance of a class would be to use the new keyword.

e.g. var sensorInfo = new Sensor.Info();

The fact…

- The posted code isn't quite right.private var _info = null;private var _barometer = Lang.Float; // [1]_info = Sensor.Info; // [2] _barometer = _info.pressure;[1] it doesn't make sense to initialize…

## All Replies

Maybe Activity.Info.ambientPressure does the trick:

### var ambientPressure as Lang.Float or Null

The ambient pressure in Pascals (Pa).

This returns ambient (local) barometric pressure as measured by the pressure sensor. The data is smoothed by a two-stage filter to reduce noise and instantaneous variation.

Hadn't looked at this API yet. Produces the same results in the simulator though:

_info = Activity.Info;;

_barometer = _info.ambientPressure;

System.println(_barometer); // null value output to debug console

System.println(_barometer.toString()); // 'Encountered app crash'

Other readings have suggested that the internal barometer is unavailable in the simulator (which makes ensuring the object works as expected difficult while testing) and to just assign a dummy float as the barometric value in simulation. Really hoping this isn't the case and I can get some pressure values within the simulator.

If you have a real device, you could try recording an activity and using that as the data source during simulation.

But for what it's worth, I tried simulating activity data with both fr955 and edge1050, and I was able to get a value from Activity.Info.ambientPressure.

1) I create a simple data field project

2) My view's compute() function looks like this:

`function compute(info as Activity.Info) as Numeric or Duration or String or Null {``   return info.ambientPressure;`` }`

3) I run the app in the simulator and press the play button () in Simulator > Activity Data. (Yes, the UI here can be confusing - this has been a problem since the beginning, even though the UI has changed quite a bit.)

3a) Before pressing play:

3b) Press play:

3c) After pressing play:

_barometer = _info.pressure;

System.println(_barometer) // this prints 'null'

System.println(_barometer.toString()) // throws errors

_barometer = _info.ambientPressure;

System.println(_barometer); // null value output to debug console

System.println(_barometer.toString()); // 'Encountered app crash'

It's expected that if you call toString() (or any other method) on a null value, your app will crash, since methods can only be called on a valid object.

Since it's valid for either Sensor.Info.pressure or Activity.Info.ambientPressure to be null (according to the API docs / type info), this is a possibility you have to account for in your code, even when it runs on a real device.

The above procedure was successful on both SDK 7.4.3 (the latest) and 7.3.0.

Since it's valid for either Sensor.Info.pressure or Activity.Info.ambientPressure to be null (according to the API docs / type info), this is a possibility you have to account for in your code, even when it runs on a real device.

For example, native Garmin data fields will often display "--" when a value is null / unavailable / not applicable.

I'll try this a bit more. I knew how to turn on the 'Activity Data' within the simulator but not about the creation of the compute() function.

Just need to figure out how to show the return within my existing app. Using the return from the compute() function still throws errors when I attempt either System.println() or dc.drawText() when passing either _barometer.format("%.2f") or _barometer.toString() as paramters.

It's expected that if you call toString() (or any other method) on a null value, your app will crash, since methods can only be called on a valid object.

As flowstate has mentioned: you have to check for null before using the value in any method:

if ( _barometer != null ) { dc.drawText(x, y, font, _barometer.format(“%.2f“), center);} else { dc.drawText(x, y, font, “ - - “ , center);}

BTW: „return value“ in function compute() works only in simple datafields, whereas dc.drawText() works in onUpdate() only in complex datafields.

ps. This is an answer to mmcleod

The reminder to check for the null value first is appreciated, made testing easier.

Ran tests on the object using both compute() and dc.drawText() within onLayout(). So far my _barometer object remains null.

This has been tested using both Activity.Info and Sensor.Info objects. Activity Data in the simulator UI is running.

Everyone's tips are appreciated.

Not sure why simulated pressure data works for the fr955 and Edge1050, and not the Edge1030 I am running.

> Not sure why simulated pressure data works for the fr955 and Edge1050, and not the Edge1030 I am running.

I just tried edge1030 and it works fine.

> I knew how to turn on the 'Activity Data' within the simulator but not about the creation of the compute() function.

The compute[] function is only relevant for a simple datafield, as in my example. If you create a simple data field project, the compute[] function will automatically be added for you [with a default return value such as 0.0]. Since your project did not have a compute[] function, I assume it is not a simple datafield.

It's only a proof of concept but I was able to display barometric pressure in an app as follows:

1] Create a simple data field project:

- Open command palette [CTRL-SHIFT-P / CMD-SHIFT-P]

- Select "Monkey C: New Project"

- Enter project name

- Select Data Field

- Select Simple

- Select API level [this shouldn't matter, just pick the lowest one]

- Select the products to support

2] Modify the compute[] function [which should be generated as part of the new project] as follows:

`// The given info object contains all the current workout``// information. Calculate a value and return it in this method.``// Note that compute() and onUpdate() are asynchronous, and there is no``// guarantee that compute() will be called before onUpdate().``function compute(info as Activity.Info) as Numeric or Duration or String or Null {``   // See Activity.Info in the documentation for available information.``   return info.ambientPressure; // <==== add this line [and remove the existing line starting with "return..."]``}`

Note that you don't need any special logic to handle null here because a simple data field is allowed to return null [in which case it will display nothing for the value], and because a Numeric value [such as a Float pressure value] will automatically be formatted as shown above.

Ofc in your real app, you will probably want special null-handling logic as in mcinner1's example, and you will probably want precise control over the formatting.

But this is just a test, so returning the value itself [Float or null] without any special formatting should be fine.

3] Run the data field in the simulator

You should see the same results as I described above [except that the data field label won't be "pressure" unless you also change the part of the code that sets the label, which isn't really necessary for the test]

Once you have satisfied yourself that pressure data is indeed being simulated and displayed by your app, you can move on to trying to figure out why it isn't being displayed in your real app.

flowstate the above mock project works and displays the pressure data. This worked using the above assumption of 'Data Field' rather than an 'App' for the project. The above template works for both Activity.Info and Sensor.Info objects.

Going to figure out why it isn't working in my app.

Toybox.Activity.Info

Toybox.Sensor.Info


We have fresh evidence from web search. Need to confirm for Fenix 5 specifically API support. Search result 9 (device reference) lists fenix5s but not details. Need fetch the specific device reference page for fenix5 to check API level. Use ctx_fetch_and_index or ollama_web_fetch. The device reference page likely has a table of device info: API level, screen, memory etc. Let's fetch.


Title: Device Reference

Content:
Device Reference

- Approach® S50
- Approach® S60
- Approach® S62
- Approach® S70 42mm
- Approach® S70 47mm
- D2™ Air
- D2™ Air X10
- D2™ Bravo
- D2™ Bravo Titanium
- D2™ Charlie
- D2™ Delta
- D2™ Delta PX
- D2™ Delta S
- D2™ Mach 1
- D2™ Mach 2
- D2™ Mach 2 Pro
- Descent™ G1 / G1 Solar
- Descent™ G2
- Descent™ Mk1
- Descent™ Mk2 / Mk2i
- Descent™ Mk2 S
- Descent™ Mk3 43mm / Mk3i 43mm
- Descent™ Mk3i 51mm
- Edge® 1030
- Edge® 1030 / Bontrager
- Edge® 1030 Plus
- Edge® 1040 / 1040 Solar
- Edge® 1050
- Edge® 130
- Edge® 130 Plus
- Edge® 520 Plus
- Edge® 530
- Edge® 540 / 540 Solar
- Edge® 550
- Edge® 820 / Explore
- Edge® 830
- Edge® 840 / 840 Solar
- Edge® 850
- Edge® 1000 / Explore
- Edge® 520
- Edge® Explore
- Edge® Explore 2
- Edge® MTB
- Enduro™
- Enduro™ 3
- epix™
- epix™ (Gen 2) / quatix® 7 Sapphire
- epix™ Pro (Gen 2) 42mm
- epix™ Pro (Gen 2) 47mm / quatix® 7 Pro
- epix™ Pro (Gen 2) 51mm / D2™ Mach 1 Pro / tactix® 7 – AMOLED Edition
- eTrex® Touch
- fēnix® 3 / tactix® Bravo / quatix® 3
- fēnix® 3 HR
- fēnix® 5 / quatix® 5
- fēnix® 5 Plus
- fēnix® 5S
- fēnix® 5S Plus
- fēnix® 5X / tactix® Charlie
- fēnix® 5X Plus
- fēnix® 6 / 6 Solar / 6 Dual Power
- fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6
- fēnix® 6S / 6S Solar / 6S Dual Power
- fēnix® 6S Pro / 6S Sapphire / 6S Pro Solar / 6S Pro Dual Power
- fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power
- fēnix® 7 / quatix® 7
- fēnix® 7 Pro
- fēnix® 7 Pro - Solar Edition (no Wi-Fi)
- fēnix® 7S
- fēnix® 7S Pro
- fēnix® 7X / tactix® 7 / quatix® 7X Solar / Enduro™ 2
- fēnix® 7X Pro
- fēnix® 7X Pro - Solar Edition (no Wi-Fi)
- fēnix® 8 43mm
- fēnix® 8 47mm / 51mm / tactix® 8 47mm / 51mm / quatix® 8 47mm / 51mm
- fēnix® 8 Pro 47mm / 51mm / MicroLED / quatix® 8 Pro 47mm / 51mm
- fēnix® 8 Solar 47mm
- fēnix® 8 Solar 51mm / tactix® 8 Solar 51mm
- fēnix® Chronos
- fēnix® E
- Forerunner® 165
- Forerunner® 165 Music
- Forerunner® 170
- Forerunner® 170 Music
- Forerunner® 230
- Forerunner® 235
- Forerunner® 245
- Forerunner® 245 Music
- Forerunner® 255
- Forerunner® 255 Music
- Forerunner® 255s
- Forerunner® 255s Music
- Forerunner® 265
- Forerunner® 265s
- Forerunner® 45
- Forerunner® 55
- Forerunner® 570 42mm
- Forerunner® 570 47mm
- Forerunner® 630
- Forerunner® 645
- Forerunner® 645 Music
- Forerunner® 70
- Forerunner® 735xt
- Forerunner® 745
- Forerunner® 920XT
- Forerunner® 935
- Forerunner® 945
- Forerunner® 945 LTE
- Forerunner® 955 / Solar
- Forerunner® 965
- Forerunner® 970
- Garmin Swim™ 2
- GPSMAP® 66s / 66i / 66sr / 66st
- GPSMAP® 67 / 67i
- GPSMAP® 86s / 86sc / 86i / 86sci
- GPSMAP® H1 / H1i Plus
- Instinct® 2 / Solar / Dual Power / dēzl Edition
- Instinct® 2S / Solar / Dual Power
- Instinct® 2X Solar
- Instinct® 3 AMOLED 45mm
- Instinct® 3 AMOLED 50mm
- Instinct® 3 Solar 45mm / 50mm
- Instinct® Crossover
- Instinct® Crossover AMOLED
- Instinct® E 40mm
- Instinct® E 45mm
- Captain Marvel
- First Avenger
- Darth Vader™
- Rey™
- MARQ® (Gen 2) Athlete / Adventurer / Captain / Golfer / Carbon Edition / Commander - Carbon Edition
- MARQ® (Gen 2) Aviator
- MARQ® Adventurer
- MARQ® Athlete
- MARQ® Aviator
- MARQ® Captain / MARQ® Captain: American Magic Edition
- MARQ® Commander
- MARQ® Driver
- MARQ® Expedition
- MARQ® Golfer
- Montana® 7 Series
- Oregon® 7 Series
- Rino® 7 Series
- Venu®
- Venu® 2
- Venu® 2 Plus
- Venu® 2S
- Venu® 3
- Venu® 3S
- Venu® 4 41mm
- Venu® 4 45mm / D2™ Air X15
- Venu® Mercedes-Benz® Collection
- Venu® Sq
- Venu® Sq 2
- Venu® Sq 2 Music
- Venu® Sq. Music Edition
- Venu® X1
- vívoactive®
- vívoactive® 3
- vívoactive® 3 Mercedes-Benz® Collection
- vívoactive® 3 Music
- vívoactive® 3 Music LTE
- vívoactive® 4
- vívoactive® 4S
- vívoactive® 5
- vívoactive® 6
- vívoactive® HR

MenuDevice Reference

Links found: 3
  - https://developer.garmin.com/
  - https://developer.garmin.com/connect-iq/device-reference/approachs50/
  - https://developer.garmin.com/connect-iq/device-reference/approachs60/

Device Reference


Device Reference


Title: Freediving Depth Data Field - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

Content:
Freediving Depth Data Field - Connect IQ App Development Discussion - Connect IQ - Garmin Forums

- Replies 12 replies
- Subscribers 20 subscribers
- Views 5584 views
- Users 0 members are here

Options

- Share
- More
- Cancel

Related

# Freediving Depth Data Field

Recently I noticed that the very useful freediving data field called "Depth" has disappeared from the Connect IQ Store. I have no Idea why and I also don't remember the author of this data field. Because I need this data field and because I want to be able to record the data, I now try to code it myself. Only problem is that I currently run into some difficulties: -There seems to be no way to get the pressure reading from the barometer into a data field, because it would use the Sensor module which is not allowed to be used for a data field, only for an app (Gives error when put in manifest file). -And taken that it could be done anyhow, it most likely could not be done with Info.pressure because according to the API documentation this would return a pressure value corrected with the current altitude, whereas I would need the raw value to calculate the diving depth. So, my big question is: How did the author of this freediving depth data field achieve this?? Can anybody give me a hint with this? PS: Yes, I know that there exists a diving computer app at www.diveiq.com. But it’s quite expensive and not ideal for freediving. What I really want is just a data field to show me the current depth, which creates a FIT-File to show the depth as a graph in Garmin Connect.

- Sign in to reply
- Cancel

## Top Replies

- Don't confuse the water rating (how deep you can take the watch) with what pressures you can read with the watch. If I recall, some devices max out pressure readings at a depth that would work for…

## All Replies

Don't confuse the water rating (how deep you can take the watch) with what pressures you can read with the watch. If I recall, some devices max out pressure readings at a depth that would work for swimming - it's so non-diving watches aren't used to record diving. If you want an Instinct for diving, there is the Descent G1: https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/garmin-introduces-the-descent-g1-series

No way...You sir just made my Day.Didn't know this existed.Price is okayisch but still on the Very Expensive side...The Max Rating is an Important Point you made here, I found https://www.apnea.me/ but their FAQ Mentions the Problem you described.Thank you, Sir.

Links found: 3
  - https://forums.garmin.com/login?ReturnUrl=%2Fdeveloper%2Fconnect-iq%2Ff%2Fdiscussion%2F4028%2Ffreediving-depth-data-field%2F1391311
  - https://forums.garmin.com/login?ReturnUrl=%2Fdeveloper%2Fconnect-iq%2Ff%2Fdiscussion%2F4028%2Ffreediving-depth-data-field%2F1391311
  - https://forums.garmin.com/apps-software/


The fetched device reference pages don't include per-device details; likely need a URL like /device-reference/fenix5/ has a page with specs but the fetch only got the menu. Maybe content is dynamic or not loaded. Could use wget? But instructions restrict. However we can use the search result content that already showed device reference link and the compatible devices matrix maybe from another page. Or fetch the page via web_explore. But the web_explore output omitted details. Maybe because output large not shown? Actually tool returned only "Reviewed 4 sources...". It may have indexed. We can use ctx_search for the indexed content from web_explore. Let's try ctx_search queries.

fenix 5 rawAmbientPressure depth accurate freediving

fenix 5 ambient pressure no cap underwater

fenix 5 CIQ API level raw ambient pressure


## fenix 5 rawAmbientPressure depth accurate freediving

--- [current-session | 2026-07-26 21:21 | batch:raw_ambient_fenix_models,fenix_depth_sensor_limits] ---
### fenix_depth_sensor_limits

# fenix_depth_sensor_limits

$ echo "Searching session memory for fēnix depth sensor caps..."

Searching session memory for fēnix depth sensor caps...

--- [current-session | 2026-07-26 21:21 | batch:raw_ambient_fenix_models,fenix_depth_sensor_limits] ---
### raw_ambient_fenix_models

# raw_ambient_fenix_models

$ echo "Searching CIQ docs for rawAmbientPressure supported fēnix models..."

Searching CIQ docs for rawAmbientPressure supported fēnix models...

---

## fenix 5 ambient pressure no cap underwater

--- [current-session | 2026-07-26 21:21 | batch:raw_ambient_fenix_models,fenix_depth_sensor_limits] ---
### raw_ambient_fenix_models

# raw_ambient_fenix_models

$ echo "Searching CIQ docs for rawAmbientPressure supported fēnix models..."

Searching CIQ docs for rawAmbientPressure supported fēnix models...

--- [current-session | 2026-07-26 21:01 | CIQ Activity Info API::https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity/Info.html] ---
### Class: Toybox.Activity.Info > Instance Attribute Details > var ambientPressure as [Lang.Float](../../Toybox/Lang/Float.html) or **Null** (1)

### var ambientPressure as [Lang.Float](../../Toybox/Lang/Float.html) or **Null**

The ambient pressure in Pascals (Pa).

This returns ambient (local) barometric pressure as measured by the pressure sensor. The data is smoothed by a two-stage filter to reduce noise and instantaneous variation.

Since:

API Level 2.4.0

Supported Devices:

---

## fenix 5 CIQ API level raw ambient pressure

--- [current-session | 2026-07-26 21:21 | batch:raw_ambient_fenix_models,fenix_depth_sensor_limits] ---
### raw_ambient_fenix_models

# raw_ambient_fenix_models

$ echo "Searching CIQ docs for rawAmbientPressure supported fēnix models..."

Searching CIQ docs for rawAmbientPressure supported fēnix models...

--- [current-session | 2026-07-26 21:01 | CIQ Activity Info API::https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity/Info.html] ---
### Class: Toybox.Activity.Info > Instance Attribute Details > var rawAmbientPressure as [Lang.Float](../../Toybox/Lang/Float.html) or **Null** (1)

### var rawAmbientPressure as [Lang.Float](../../Toybox/Lang/Float.html) or **Null**

The raw ambient pressure in Pascals (Pa).

This returns ambient (local) barometric pressure as measured by the internal pressure sensor. The data is the temperature compensated information read directly from the internal sensor.

Since:

API Level 2.4.0

Supported Devices:

> Throttle: call #1/8 in this window. 2 call(s) before soft cap. Prefer ctx_search(queries: [...]) array form for multi-query workloads — it counts as a single call.


The ctx_search results show session memory but the "Supported Devices" lists are empty maybe because content after that not indexed? Could be due to JS in page. We can fetch the API docs directly using ctx_fetch_and_index or ollama_web_fetch? Already fetch returned full page with list of supported devices maybe omitted? The snippet didn't include the supported devices list. Let's fetch the API page with ctx_fetch_and_index so it can be searched. But it may not get dynamic. The page content from ollama fetch did include rawAmbientPressure details but didn't include "Supported Devices" likely because it's in a table loaded after? Let's scroll? Maybe the API doc uses anchor page with device list hidden. Another way: look at the Garmin Connect IQ compatible devices page, maybe an XML with devices and API levels. Or use the SDK device.xml? We don't have SDK installed. We can perhaps download the device compat matrix. But maybe not needed. The user wants confirmation: Does Fenix 5 API measure underwater distance? We know rawAmbientPressure is available API 2.4+. Need confirm Fenix 5 supports API 2.4+. We have summary that says yes. Also search results include forum quote: "Depends on which watch you're developing for. For fenix 5 you can read raw pressure. I built exactly this data field today." This directly answers yes. We can quote. Also "I've created fenix 5 series and vaHR compatible version." It says SDK 2.4 introduced ambientPressure etc. The f5 supports it. Need to verify API level of Fenix 5: maybe 3.1.x. Let's search.

Question: Garmin fēnix 5 Connect IQ API level 3.1 compatible devices

Question: "fenix 5" "rawAmbientPressure" "depth" forum accurate freediving