You'll need to install a library to make Arduino IDE support the module. This library includes drivers for the MMA8491Q and sample code for you to jumpstart your project.
For ESP32 based systems, we're currently supporting Arduino core. Please make sure you've installed the following:
- Arduino IDE.
- ESP32 Hardware libraries for the Arduino IDE.
- Python for the compilation of Arduino projects.
- Drivers for your host device, e.g., USB Virtual Serial Port driver.
Then, copy its contents to your Arduino Libraries folder.
You can find the Arduino Libraries folder inside your Arduino sketch directory. It is generally located inside the My Documents folder.
The library comes with included samples. There is no need to download additional files for the examples.
The hardware, its drivers and the sample code are open source. You can use them under the terms of the MIT license. Please feel free to customize and prototype them for your projects.
Turta_AccelTilt_Module library is responsible for reading the accelerometer and tilt data.
To use the library on Arduino IDE, add the following #include statement to the top of your sketch.
Then, create an instance of the Turta_AccelTilt_Module class.
Now you're ready to access the library by calling the accel instance.
To initialize the module, call the begin method.
This method configures the I2C bus and GPIO pins to read sensor data.
Returns the G value of the X axis.
- Double: G Value of the X axis.
Returns the G value of the Y axis.
- Double: G Value of the Y axis.
Returns the G value of the Z axis.
- Double: G Value of the Z axis.
Returns the values of all axes in a single shot.
void readXYZAxis(double x, double y, double z)
- Double: x out
- Double: y out
- Double: z out
Returns the tilt state of all axes.
void readTiltState(bool xTilt, bool yTilt, bool zTilt)
- Bool: xTilt out
- Bool: yTilt out
- Bool: zTilt out
You can open the example from Arduino IDE > File > Examples > Examples from Custom Libraries > Turta Accel & Tilt Module. There are two examples of this sensor.
If you're experiencing difficulties while working with your device, please try the following steps.
Problem: When using the single shot reading function, Y-axis returns 0 G. Cause: There is a software communication error on the I2C bus. Solution: It's a known issue, and we're working on to fix this bug. Until then, please use the single reading functions. It's not a malfunction.