MMA8491Q Accel Tilt Sensor
This documentation includes installation guidelines and sample code for your hardware.
Python Library
Turta_MMA8491Q library is responsible for communicating with the MMA8491Q sensor.
To install the library from the (PyPI) Python Package Index, enter the following command to the console.
Add the following statement to the top of your Python code.
Then, create an instance of the Turta_MMA8491Q class.
Now you're ready to access the library by calling the mma8491q instance.
Initialization
The library automatically initializes the required components when its instance is being created, so there is no need to do a manual initialization.
Basic Members
Read X Axis
Reads the X-axis G value.
Parameters
None
Returns
Float: X-axis G value.
Read Y Axis
Reads the Y-axis G value.
Parameters
None
Returns
Float: Y-axis G value.
Read Z Axis
Reads the Z-axis G value.
Parameters
None
Returns
Float: Z-axis G value.
Read XYZ Axis
Reads the X, Y and Z-Axis G values respectively.
Parameters
None
Returns
Float[]: 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.
Samples
You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Raspbian/Python address, and then copy it to the Raspberry Pi. There is one example of this library.
MMA8491Q Sample App
This application demonstrates printing accel and tilt readings from the sensor.
To run the example:
Copy the library and sample code to a folder on the Raspberry Pi.
Open terminal, and go to the folder you copied the codes.
Run the sample with the following command:
Sample Code
Result
When you run the sample, it prints X, Y, and Z axis G readings and tilt state to the terminal. The example output should be like this:
To stop the Python script, just press CTRL + C.
Last updated