MainSpring Blog

New for FileMaker 17: GetSensor function

Written by Mike Beargie | May 15, 2018 at 1:00 PM

FileMaker 17 introduced the new GetSensor function as a new mobile function available for use in FileMaker Go apps. With this new function, you can gather sensor data from an iOS device and use it programmatically in your custom app.

While this is a good start, there’s still some device metadata and sensor data that is not available from the function. A few years ago, I released a metadata gathering app, CoreScope, that allows for more information to be gathered from the device. Due to my familiarity with iOS programming and sensors, I found some parts of FileMaker’s documentation on this function to be a little confusing. So, I dug deeper into Apple’s developer documentation to put together the below chart explaining in detail what each sensor reading represents.

Use these helpful tables in order to understand and use sensors with the GetSensor() function.

Configuration

Parameter name Description Example usage Example result
available Returns a list of which sensors are available for use on the current device. GetSensor(“available”) Battery
Magnetic
Step count

 

Battery sensor

Parameter name Description Example usage Example result
batteryLevel Returns a decimal representing the battery charge level between 0.0 and 1.0 GetSensor(“batteryLevel”) .76
batteryStatus Returns the power charging status for result; EG if a device is unplugged or not. GetSensor(“batteryStatus”) 1

1 = unplugged, 2 = charging, 3 = plugged in and full

 

Location sensor

(Note that if the optional accuracy and timeout parameters are not specified, a default accuracy of 100 meters and 10 seconds is used.)

Parameter name Description Example usage Example result
location The same as the existing Location() function. Returns latitude, longitude, horizontal accuracy. GetSensor(“location”;50;10)

50 = Accuracy
10 = Timeout in Seconds
+37.343123, -122.017593, +65.000000
locationValues The same as the existing LocationValues() function. Returns latitude, longitude, altitude, horizontal accuracy, vertical accuracy, age. GetSensor(“locationValues”;50;10)

50 = Accuracy
10 = Timeout in Seconds
37.406489
-121.983428
0.0545050
65
10
0.001236

 

Attitude, speed & acceleration sensor

(Note that if the optional accuracy and timeout parameters are not specified, a default accuracy of 100 meters and 10 seconds is used.)

Parameter name Description Example usage Example result
attitude roll, pitch, yaw in radians GetSensor(“attitude”) 2
1
4
rotationRate x, y, z measured in radians per second GetSensor(“rotationRate”) .1
.4
0
accelerationByUser x, y, z values for acceleration by user in respect to the current attitude in meters/seconds2 GetSensor(“accelerationByUser”) 23
1
3
accelerationByGravity x, y, z values for acceleration by gravity with respect to current attitude in meters/seconds2 GetSensor(“accelerationByGravity”) .8
.01
.2
speed Returns the current speed at the time of reading in meters per second. GetSensor(“speed”;50;10)

50 = Accuracy
10 = Timeout in Seconds
1.2
heading Returns the current direction of movement in degrees (0.0 - 359.9). GetSensor(“heading”;50;10)

50 = Accuracy
10 = Timeout in Seconds
254.8

 

Magnetic sensor

(Note that if the optional accuracy and timeout parameters are not specified, a default accuracy of 100 meters and 10 seconds is used.)

Parameter name Description Example usage Example result
magneticField The geomagnetic data (measured in microteslas) for the x, y and z-axis. GetSensor("magneticField") 30
24
60
compassMagneticHeading degrees (0.0 - 359.9) between magnetic north and current attitude GetSensor("compassMagneticHeading";50;10)

50 = Accuracy
10 = Timeout in Seconds
104.8
compassTrueHeading degrees (0.0 - 359.9) between true north and current attitude GetSensor("compassTrueHeading";50;10)
50 = Accuracy
10 = Timeout in Seconds
100.8

 

Step count sensor

(Note that if the optional second parameter is not specified, it returns the values measured since midnight of the current day. The sensor can be inaccurate if the user has not calibrated their phone’s step settings inside of health data and motion calibration. Also, returned measurements may be localized to the user’s iOS localization settings, eg. meters vs. feet.)

Parameter name Description Example usage Example result
stepCount Returns the number of steps taken in the past specified seconds value, or from midnight if no number is specified. GetSensor(“stepCount”)
GetSensor(“stepCount”;10)
4000
3
stepDistance Measure of distance while walking during the specified time elapsed (or midnight by default). GetSensor(“stepDistance”)
GetSensor(“stepDistance”;10)
2400
4
stepFloorsUp Measured in number of floors, the number ascended in the last specified seconds (or default of midnight). GetSensor(“stepFloorsUp”)
GetSensor(“stepFloorsUp”;1000)
22
5
stepFloorsDown The number of floors descended since seconds specified or midnight (default). GetSensor(“stepFloorsDown”)
GetSensor(“stepFloorsDown”;300)
15
3

 

Air pressure sensor

Parameter name Description Example usage Example result
airPressure Returns air pressure as measured in kilopascals GetSensor(“airPressure”) 101.325