Access phone data such as the gyroscope with Mendix

0
Hi, Would it be possible with Mendix to access data collected by your phone's gyroscope for instance? We would like to collect some data from a phone for instance GPS, gyroscope and accelerometer data to measure how a car or train is moving and shaking. Kind regards, Martin
asked
2 answers
1

Although I don't see gyroscope support in the standard list (here), there do seem to be multiple Cordova plugins for it: here and here.

answered
1

Hi Martin,

Absolutely. This is achieved in two steps:

  1. Cordova plugins that make the device sensors available via JavaScript objects/functions
  2. Mendix widgets which use those JavaScript functions and provide something meaningful to the app, whether it's writing to your data model or providing some UI element.

 

If we take Geolocation for example, here's an existing widget in the App Store that provides the function of returning latitude and longitude to an object and calling a microflow. This widget uses the Cordova GeoLocation plugin to retrieve the lat and lon. If you look at the docs for that plugin, it can also provide heading, speed, and altitude as well:

position.coords.heading
position.coords.speed
position.coords.altitude

Making these properties available to your Mendix app would involve simply adjusting the custom widget to read those values as well.

Here are links to the plugins for the gyroscope and accelerometer as well.

If you need help building these widgets, Mendix Expert Services can help you, as can a number of our partners and community members. Good luck!

answered