vignesh rajendiran
Understanding the accelerometer sensor in devices using the AppGyver application
What is the accelerometer's usage in mobile phones?
Mobile phones use accelerometers to measure the acceleration of the mobile, such as swinging, shaking, tilting, and rotating. The orientation change of the screen is based on the values provided by the accelerometer sensors only.

The accelerometer in our mobile provides us with three values X,Y, and Z, which denote the direction and position of the device. Most of the time, accelerometer sensor values and gyroscope sensor values are combined in order to provide a very accurate reading. Gyroscope sensors will be discussed in detail in another blog.
How are these values available to us in the Appgyver mobile application?
The accelerometer sensor variable which provides X,Y, and Z values in the form of an object is sensorVars.accelerometer.latestValue.

Now let's see how this works.
The accelerometer in our mobile provides us with three values X, Y, and Z, which denote the direction and position of the device. Most of the time, accelerometer sensor values and gyroscope sensor values are combined in order to provide a very accurate reading. Gyroscope sensors will be discussed in detail in another blog.

As the sensor variable returns the values as an object, we can segregate the X, Y, and Z values using sensorVars.accelerometer.latestValue.x, sensorVars.accelerometer.latestValue.y and sensorVars.accelerometer.latestValue.x in formula binding option.

Now the application will look like below in the SAP AppGyver preview app.

As we have not requested the mobile to provide accelerometer details for our application, the values of sensorVars.accelerometer.latestValue.x, sensorVars.accelerometer.latestValue.y and sensorVars.accelerometer.latestValue.x are undefined.
How to request accelerometer details in an AppGyver application?
If you search for accelerometer in the flow function market, you will get all the flow functions related to accelerometer, such as Start accelerometer poller, Stop accelerometer poller, and get single accelerometer poller. Go ahead and install the Start and Stop accelerometer poller, which can be seen in the Installed tab of the logic section.

Now drag and drop the Start accelerometer poller to the logic of the page mount event like shown below.

In the SAP AppGyver preview app, the application appears as shown below.


After allowing device location access for the application, we can see the X, Y, and Z values are getting fetched into the application.
Note: Providing a device location for this will not turn on your GPS.
I can understand that it is a bit confusing by just looking at the axis arrow in the above article image. Accelerometer sensors will not provide the same range of values across the devices. It varies from one device to another depending on the hardware sensor.
Understanding X, Y, and Z values during shaking the device
When you shake your device very hard, the X,Y, and Z values will be very high based on your movement.
Understanding X, Y, and Z values during tilting and rotating the device
For tilting and rotating, the accelerometer sensor values of my current device range from -10 to 10 m/s. Let me explain each value in detail below.
X Values

I have my mobile in front of me in landscape mode on the table. The value of X range is -10 to 10 for my device, as I mentioned. If I rotate the device towards the right hand side, the X value will be 0 at the plan surface and will be around -10 when it is 90 degrees, and it will reduce back to 0 when the device screen is facedown on the table. If I rotate the device towards the right hand side, the X value will be 0 at the plan surface and will be around -10 when it is 90 degrees, and it will reduce back to 0 when the device screen is facedown on the table.

Y Values

I have my mobile in front of me in portrait mode on the table. The value of the Y range is -10 to 10 for my device, as I mentioned. If I rotate the device towards your side, the Y value will be 0 at the plan surface and will be around -10 when it is 90 degrees, and it will reduce back to 0 when the device screen is facedown on the table. If I rotate the device towards the opposite of your side, the Y value will be 0 at the plan surface and will be around -10 when it is 90 degrees, and it will reduce back to 0 when the device screen is facedown on the table.

Z Values

I have my mobile in front of me inclined to 45 degrees on the table. The value of the Z range is -10 to 10 for my device, as I mentioned. If I rotate the device towards the right hand side, the z value will be 10 at the plan surface. It will be 0 when it is 90 degrees, and it will be reduced to -10 when the device screen is facedown on the table. If I rotate the device towards the right hand side, the Z value will be 10 at the plan surface. It will be 0 when it is 90 degrees, and it will be reduced to -10 when the device screen is facedown on the table.

Check out my next post to create a dynamic text, border and background colors using accelerometer sensors. Suggestions and feedback are much appreciated. It encourages me to improve and share more content based on my experience with no-code tools. If you have any doubts or queries, drop them in the comment section.