SparkFun Qwiic 3-Axis Accelerometer (ADXL313) Hookup Guide

Contributors: santaimpersonator, QCPete
Favorited Favorite 3

Python Examples

There are several examples written for the Qwiic_ADXL313_Py Python package. They can be found in the Examples folder of the GitHub repository or view on the repository documentation page, hosted on ReadtheDocs. Users can also grab them here, using the link below. (*Please be aware of any package dependencies.):

Example 1 - Basic Readings

This example is hosted on ReadtheDocs: Example 1.

reading raw data
Raw data readings for ADXL313. (Click to enlarge)

This example outputs the raw acceleration values read by the sensor. To convert the values, use the following equation.

In this example, g-range = 2 and the resolution = 10-bits = 1024; therefore the measured acceleration (g's):

Example 3 - Auto. Sleep

This example is hosted on ReadtheDocs: Example 3.

sensor entering sleep mode and waking up
Raw data readings with indicators for when the sensor detects inactivity and enters auto-sleep. (Click to enlarge)

After the sensor detects inactivity for more than 5 seconds, it will automatically enter sleep mode and stop recording data into the FIFO. This conserves power to the accelerometer.

Note: The senor has to be relatively flat on the x-axis in order for it to enter sleep mode. Therefore, users may need to play with a level if their desk isn't level or flat.

Otherwise, users can change the threshold on line 74: myAdxl.setActivityThreshold(10) # 0-255 (62.5mg/LSB) to a higher value, like 40 to increase the inactivity threshold. This means the sensor doesn't have to lie precisely flat, but also means that the sensor requires more acceleration to wake up as well.