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.
Interested in a deeper dive? Let me know in the comments, and I can link you to Apple’s documentation.
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 |
About the Author
Mike Beargie has been with MainSpring since 2013 and has over 10 years of application development experience. As a developer, he creates solutions for clients in a wide variety of sectors across the U.S. and abroad. Prior to working at MainSpring, Mike worked as the lead developer for a consulting company, serving high profile political, special interest and nonprofit clients in the Washington, D.C., and Columbus, Ohio, markets. Mike regularly presents solutions and best practices to the FileMaker development community around the country, and is well known as an answer man online as well. In 2014 and 2016, Mike was recognized with the FileMaker Excellence Award for community contributions. Mike is a man of many hobbies, including woodworking, home brewing, art and music.