MMA8491Q Accel Tilt Sensor
This documentation includes installation guidelines and sample code for your hardware.
Windows 10 IoT Core Library
MMA8491QSensor library is responsible for communicating with the MMA8491Q accel and tilt sensor.
To use the library, add the following using statement to the top of your C# code.
Then, create an instance of the MMA8491QSensor class.
Now you're ready to access the library by calling the accel instance.
Initialization
MMA8491QSensor
Initiates the MMA8491Q sensor to get 3D acceleration data and tilt interrupt.
Parameters
Enum Modes sensorMode:
Accelerometer: Initiates the library with accelerometer settings.
TiltSensor: Initiates the library with the tilt sensor settings.
Basic Members
Read X Axis
Reads the X-axis G value.
Parameters
None
Returns
Double: X-axis G value.
Read Y Axis
Reads the Y-axis G value.
Parameters
None
Returns
Double: Y-axis G value.
Read Z Axis
Reads the Z-axis G value.
Parameters
None
Returns
Double: Z-axis G value.
Read XYZ Axis
Reads the X, Y and Z-Axis G values respectively.
Parameters
None
Returns
Double[]: X, Y and Z-Axis G values respectively.
Read Tilt State
Reads the tilt state.
Parameters
None
Returns
Bool: Tilt state. Returns True if acceleration is > 0.688g or X/Y axis > 43.5. False if not.
Interrupts
Tilt Changed
Notifies on sensor tilt change.
Event Args
Bool TiltDetected: Returns True if acceleration is > 0.688g or X/Y axis > 43.5. False if not.
Disposal
To clean up the resources used by the class, call the Dispose() method it when the application is closing.
This method stops the timers and cleans the resources used by the class.
Samples
You can copy the example codes from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Windows10IoTCore address. There are two examples of this library.
Accel Sample App
This application demonstrates reading 3D acceleration data from the sensor.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, it prints the 3D acceleration reading to the Visual Studio Output / Immediate Window.
To stop the application, use the "Stop" button on the Visual Studio.
Tilt Detect Sample App
This application demonstrates reading tilt interrupts from the sensor.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, it prints tilt change interrupts to the Visual Studio Output / Immediate Window.
To stop the application, use the "Stop" button on the Visual Studio.
Last updated