# Analog Devices ADXL343 Breakout Learning Guide

## Overview

Analog Devices has followed up on their popular classic, the ADXL345, with this near-drop-in-replacement, the ADXL343. Like the original, this is a triple-axis accelerometer with digital I2C and SPI interface breakout.

It has a wide sensitivity range and high resolution, operating with an 10 or 13-bit internal ADC. Built-in motion detection features make tap, double-tap, activity, inactivity, and free-fall detection trivial. There's two interrupt pins, and you can map any of the interrupts independently to either of them

![](https://cdn-learn.adafruit.com/assets/assets/000/122/962/medium800/sensors_4097-05.jpg?1690378016)

The ADXL343 is nearly identical in specifications to the ADXL345, and code written for the '345 will likely work on the '343 as-is. This new accelerometer has some nice price improvements to stay within your budget.

The sensor has three axes of measurements, X Y Z, and pins that can be used either as I2C or SPI digital interfacing. You can set the sensitivity level to either +-2g, +-4g, +-8g or +-16g. The lower range gives more resolution for slow movements, the higher range is good for high speed tracking. The ADXL343 is the latest and greatest from Analog Devices, known for their exceptional quality MEMS devices.

![](https://cdn-learn.adafruit.com/assets/assets/000/122/963/medium800/sensors_4097-10.jpg?1690378028)

As if that weren't enough, we've also added[&nbsp;SparkFun qwiic](https://www.sparkfun.com/qwiic)&nbsp;compatible&nbsp;**[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt)**&nbsp;connectors for the I2C bus **so you don't even need to solder.** Just wire up to your favorite micro with a plug-and-play cable to get accelerometer data ASAP. For a no-solder experience,&nbsp;[just wire up to your favorite micro](https://www.adafruit.com/category/621) using a&nbsp;[STEMMA QT adapter cable.](https://www.adafruit.com/?q=stemma%20qt%20cable)&nbsp;The Stemma QT connectors also mean the ADXL can be used with our&nbsp;[various associated accessories.](https://www.adafruit.com/?q=JST%20SH%204)&nbsp;[QT Cable is not included, but we have a variety in the shop](https://www.adafruit.com/?q=stemma+qt+cable&sort=BestMatch)

![](https://cdn-learn.adafruit.com/assets/assets/000/122/964/medium800/sensors_4097-11.jpg?1690378049)

We added an on-board 3.3V regulator and logic-level shifting circuitry, making it a perfect choice for interfacing with any 3V or 5V microcontroller or computer such as Arduino or Raspberry Pi. We even have library and example code for both Arduino/C++ and CircuitPython, so you can get started super fast with any platform!

Each order comes with a fully tested and assembled breakout and some header for soldering to a PCB or breadboard. Comes with 9 pin 0.1" standard header in case you want to use it with a breadboard or perfboard. Two 2.5mm (0.1") mounting holes for easy attachment.You'll be up and running in under 5 minutes!

[Thanks to Digi-Key](https://www.digikey.com/) and [Analog Devices](https://www.analog.com/en/index.html) for sponsoring the development of this breakout board - we've made the PCB "[Digi-Key red](https://www.digikey.com/)" in their honor!

![](https://cdn-learn.adafruit.com/assets/assets/000/122/965/medium800/sensors_4097-09.jpg?1690378079)

# Technical Characteristics

- 3-axis MEMs digital accelerometer
- Input voltage: 2.0-3.6 V
- User-selectable output resolution:
  - **+/- 2 g** (10-bit data, or +/- 512)
  - **+/- 4 g** (11-bit data, or +/- 1024)
  - **+/- 8g** (12-bit data, or +/- 2048)
  - **+/- 16 g** (13-bit data, or +/- 4096)

- User-selectable data rate (0.1 .. 3200 Hz)
- Hardware support for free-fall detection, tap detection, and activity/inactivity
- HW support for both I2C and SPI, although I2C is recommended for ease of use.

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/071/839/medium800/sensors_4097_kit_ORIG_2019_02.jpg?1550884758)

# Analog Devices ADXL343 Breakout Learning Guide

## Pinout

The ADXL343 breakout has the following pinout:

![](https://cdn-learn.adafruit.com/assets/assets/000/110/000/medium800/sensors_cropped_4097-05.png?1647977473)

![](https://cdn-learn.adafruit.com/assets/assets/000/071/841/medium800/sensors_4097_kit_ORIG_2019_pinout.png?1550885215)

# Power Pins

This breakout board can be run on&nbsp; **3.3V** and&nbsp; **5V** systems, although only the&nbsp; **SCL&nbsp;** and&nbsp; **SDA** lines are 5V safe (other pins like INT will need to be manually level-shifted by you).

- **VIN** - This is the input to the 3.3V voltage regulator, which makes it possible to use the 3.3V sensor on 5V systems. It also determines the logic level of the SCL and SDA pins. Connect this to&nbsp; **3.3V** on the MCU for 3.3V boards (Adafruit Feathers), or&nbsp; **5.0V** for 5V Arduinos (Arduino Uno, etc.).
- **3V3** &nbsp;- This is the&nbsp; **OUTPUT** of the 3.3V regulator, and can be used to provide 3.3V power to other parts of your project if required (\<100mA).
- **GND** - Connect this to the&nbsp; **GND** pin on your development board to make sure they are sharing a common GND connection, or the electrons won't have anywhere to flow!

Warning: 

# I2C Pins

- **SCL** - The clock line on the I2C bus. This pin has an internal pullup resistor on the PCB, which is required as part of the I2C spec, meaning you don't need to add one externally yourself. This also functions as&nbsp; **SCK** in SPI mode.
- **SDA** &nbsp;- The data line on the I2C bus. This pin has an internal pullup resistor on the PCB, which is required as part of the I2C spec, meaning you don't need to add one externally yourself. This also functions as&nbsp; **MOSI** in SPI mode.
- [**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt) **-** These connectors allow you to connect to development boards with **STEMMA QT** connectors, or to other things, with [various associated accessories](https://www.adafruit.com/category/619).

Info: 

# Other Pins

- **SDO/ALT ADDR** - This pin can be used as **MISO** in SPI mode, but is more commonly used&nbsp;as an optional bit in the I2C bus address.&nbsp; By default this pin is pulled down, meaning it has a value of&nbsp; **0** at startup, which will results in an I2C address of&nbsp; **0x53**. If you set this pin high (to 3.3V), and reset, the I2C address will be updated to&nbsp; **0x1D**.
- **CS** : This dual purpose pin can be used as the chip select line in SPI mode, but also determines whether the board will boot up into I2C or SPI mode. The default of logic high sets the board up for I2C, and manually setting this pin low and resetting will cause the device to enter SPI mode. Please note that SPI mode is not actively support and the SPI pins are not all 5V safe and level shifted, so care will be required when using it!
- **INT1** and&nbsp; **INT2** : There are two optional interrupt output pins on this sensor, which can be configured to change their state when one or more 'events' occur. For details on how to use these interrupts, see the Arduino/HW Interrupts page later in this guide.

# LED Jumper

- **LED jumper** - This jumper is located on the back of the board. Cut the trace on this jumper to cut power to the "on" LED.

# Analog Devices ADXL343 Breakout Learning Guide

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/073/320/medium800/sensors_4097-01.jpg?1552946883)

## Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard -&nbsp; **long pins down**

![sensors_DSC_4062.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/322/medium640/sensors_DSC_4062.jpg?1552947030)

![sensors_DSC_4066.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/323/medium640/sensors_DSC_4066.jpg?1552947085)

![sensors_DSC_4067.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/347/medium640/sensors_DSC_4067.jpg?1552948217)

## Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

![sensors_DSC_4068.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/351/medium640/sensors_DSC_4068.jpg?1552947981)

## And Solder!

Be sure to solder all 9 pins for reliable electrical contact.  
  
_(For tips on soldering, be sure to check out our&nbsp;_[_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)._

![sensors_DSC_4071.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/330/medium640/sensors_DSC_4071.jpg?1552947279)

![sensors_DSC_4076.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/332/medium640/sensors_DSC_4076.jpg?1552947324)

![sensors_DSC_4078.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/334/medium640/sensors_DSC_4078.jpg?1552947353)

![sensors_DSC_4080.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/336/medium640/sensors_DSC_4080.jpg?1552947533)

You're done! Check your solder joints visually and continue onto the next steps

![sensors_DSC_4082.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/344/medium640/sensors_DSC_4082.jpg?1552948238)

# Analog Devices ADXL343 Breakout Learning Guide

## Special HW Features

While the ADXL343 shares some things in common with most other general-purpose 3-axis accelerometers, it has the following additional features to make it easier to use in certain situations. Because these are implemented in HW inside the sensor, there is a lot less heavy lifting to do on the MCU side.

## Freefall Detection

You can use this accelerometer to detect a freefall condition (device falling off a desk, etc.) with user-defined thresholds, and one or the two INT pins can be setup to fire when a freefall condition is detected, allowing you to shut any motors or moving parts off, or indicate in a logging system that the data may not be valid (such as a plant sensor in a pot that likely got knocked over by the wind).

## Activity/Inactivity Detection

Rather that constantly polling an accelerometer to see if movement is detected, you can configure the ADXL343 to let you know when their is (one or both of) activity or inactivity on the device, with user-adjustable thresholds. This can be configure to fire an INT pin, which you could use to wakeup your device, for example, or put it to sleep after a certain amount of inactivity.

## Tap/Double-Tap Detection

Rather than having to do complex tap and double-tap detection of the device by anaylzing the magnitude of acceleration changes over time, you can detect a 'tap' or 'double-tap' of your device in HW, and fire one of the INT pins when the event is detected, significantly reducing the code and data parsing on the MCU side.

See the&nbsp; **HW Interrupts** page later in this guide for details on how to use these features in practice!

# Analog Devices ADXL343 Breakout Learning Guide

## Arduino

# Wiring

Hooking up the ADXL343 to your Arduino is easy:

Info: 

- Connect&nbsp; **SCL** &nbsp;on the Metro to **SCL** **(yellow wire)** on the ADXL343
- Connect&nbsp; **SDA** &nbsp;on the Metro to **SDA** **(blue wire)** in the ADXL343
- Connect&nbsp; **GND** &nbsp;on the Metro to **GND (black wire)** on the ADXL343
- For&nbsp; **3.3V LOGIC** &nbsp;boards: connect&nbsp; **3.3V** on the Arduino/Metro to&nbsp; **VIN** **(red wire)** on the ADXL343
- For&nbsp; **5.0V LOGIC&nbsp;** boards: Connect&nbsp; **5V** on the Arduino/Metro to&nbsp; **VIN** **(red wire)** on the ADXL343

![sensors_metroStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/009/medium640/sensors_metroStemma_bb.png?1647980528)

![sensors_metroBreadboard_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/010/medium640/sensors_metroBreadboard_bb.png?1647980544)

![sensors_OriginalmetroBreadboard_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/012/medium640/sensors_OriginalmetroBreadboard_bb.png?1647980725)

The final results should resemble the illustration above, showing an Adafruit Metro development board.

Info: 

# Installation

The Adafruit\_ADXL345 library can be installed using the Arduino&nbsp; **Library Manager** , accessible through the&nbsp; **Manage Libraries ...** menu item.

![](https://cdn-learn.adafruit.com/assets/assets/000/071/417/medium800/sensors_managelib.png?1550589163)

Click the&nbsp; **Manage Libraries ...** menu item, search for **Adafruit ADXL343** ,&nbsp;and select the&nbsp; **Adafruit ADXL343** library:

![](https://cdn-learn.adafruit.com/assets/assets/000/071/418/medium800/sensors_Screenshot_2019-02-19_at_16.13.35.png?1550589243)

# Load Example

To make sure that everything is wired up correctly, you can run the&nbsp; **sensorttest** example available in the&nbsp; **Adafruit\_ADXL343** examples folder, loadable via the&nbsp; **File -\> Examples -\> Adafruit ADXL343&nbsp;**** -\>&nbsp;sensortest** menu item.

Upload the sketch to your board and open up the Serial Monitor ( **Tools-\>Serial Monitor** ). You should see some acceleration data for for X/Y/Z.

https://github.com/adafruit/Adafruit_ADXL343/blob/master/examples/sensortest/sensortest.ino

You should get something resembling the following output when you open the Serial Monitor at **115200 baud** :

![](https://cdn-learn.adafruit.com/assets/assets/000/071/450/medium800/sensors_Screenshot_2019-02-19_at_20.22.44.png?1550604179)

# Setting the Range

You can adjust the response range of the accelerometer by setting an appropriate value in your&nbsp; **setup** loop, using one of the lines in the code shown below:

```
/* Set the range to whatever is appropriate for your project */
accel.setRange(ADXL343_RANGE_16_G);
// accel.setRange(ADXL343_RANGE_8_G);
// accel.setRange(ADXL343_RANGE_4_G);
// accel.setRange(ADXL343_RANGE_2_G);

```

By default, the sensor will be set to the maximum range of&nbsp; **+/- 16g**.

# Analog Devices ADXL343 Breakout Learning Guide

## HW Interrupts

## Interrupt Events

The ADXL343 includes two configurable HW interrupt pins, where one or more of the following events can be 'mapped' to one of the interrupt pins:

- **Overrun** : The overrun bit is set when new data replaces unread data. This can be useful in situations where it's important to know if any data samples were 'skipped', such as in sensor fusion algorithms that depend on a specific sample rate for the best possible results.
- **Watermark** : This can be used with register 0x38 **(FIFO\_CTL**) to trigger an interrupt when a user-specified number of samples are available in the internal FIFO buffer.
- **Freefall** :&nbsp;The FREE\_FALL bit is set when acceleration of less than the value stored in the THRESH\_FF register (Address 0x28) is experienced for more time than is specified in the TIME\_FF register (Address 0x29) on all axes (logical AND). The FREE\_FALL interrupt differs from the inactivity interrupt as follows: all axes always participate and are logically AND’ed, the timer period is much smaller (1.28 sec maximum), and the mode of operation is always dc-coupled.
- **Inactivity** :&nbsp;The inactivity bit is set when acceleration of less than the value stored in the THRESH\_INACT register (Address 0x25) is experienced for more time than is specified in the TIME\_INACT register (Address 0x26) on all participating axes, as set by the ACT\_INACT\_CTL register (Address 0x27). The maximum value for TIME\_INACT is 255 sec.
- **Activity** :&nbsp;The activity bit is set when acceleration greater than the value stored in the THRESH\_ACT register (Address 0x24) is experienced on any participating axis, set by the ACT\_INACT\_CTL register (Address 0x27).
- **Double Tap** :&nbsp;The DOUBLE\_TAP bit is set when two acceleration events that are greater than the value in the THRESH\_TAP register (Address 0x1D) occur for less time than is specified in the DUR register (Address 0x21), with the second tap starting after the time specified by the latent register (Address 0x22) but within the time specified in the window register (Address 0x23). See the Tap Detection section for more details.
- **Single Tap** :&nbsp;The SINGLE\_TAP bit is set when a single acceleration event that is greater than the value in the THRESH\_TAP register (Address 0x1D) occurs for less time than is specified in the DUR register (Address 0x21).
- **Data Ready** :&nbsp;The DATA\_READY bit is set when new data is available and is cleared when no new data is available.

## Mapping Interrupts to INT1/INT2

The first step to enable interrupts in your sketch is to 'map' one or more interrupt functions to either the&nbsp; **INT1** or&nbsp; **INT2** pins. This can be accomplished with the following function in&nbsp; **Adafruit\_ADXL343** :

```
bool mapInterrupts(int_config cfg);
```

`cfg` is an 8-bit bit-field where setting the individual interrupt bit to&nbsp; **1** will cause the interrupt to be mapped to&nbsp; **INT2** , and setting the interrupt bit to&nbsp; **0** will map if to&nbsp; **INT1**. The following code shows how this works in practice (based on the ``g_int_config_map`` variable in the **interrupts.ino** &nbsp;example sketch):

```
/* Map specific interrupts to one of the two INT pins. */
g_int_config_map.bits.overrun    = ADXL343_INT1;
g_int_config_map.bits.watermark  = ADXL343_INT1;
g_int_config_map.bits.freefall   = ADXL343_INT1;
g_int_config_map.bits.inactivity = ADXL343_INT1;
g_int_config_map.bits.activity   = ADXL343_INT1;
g_int_config_map.bits.double_tap = ADXL343_INT1;
g_int_config_map.bits.single_tap = ADXL343_INT1;
g_int_config_map.bits.data_ready = ADXL343_INT2;
accel.mapInterrupts(g_int_config_map);
```

## Enabling Interrupts

After mapping specific interrupt events to either INT1 or INT2, you need to 'enable' the interrupt via a second function:

```
bool enableInterrupts(int_config cfg);
```

An example of enabling the&nbsp; **OVERRUN** and&nbsp; **DATA READY** interrupts is shown below:

```
/* Enable interrupts on the accelerometer. */
g_int_config_enabled.bits.overrun    = true;    /* Set the INT1 */
g_int_config_enabled.bits.watermark  = false;
g_int_config_enabled.bits.freefall   = false;
g_int_config_enabled.bits.inactivity = false;
g_int_config_enabled.bits.activity   = false;
g_int_config_enabled.bits.double_tap = false;
g_int_config_enabled.bits.single_tap = false;
g_int_config_enabled.bits.data_ready = true;    /* Set to INT2 */
accel.enableInterrupts(g_int_config_enabled);
```

## Connecting ADXL343 INT pins to the MCU

In order to 'detect' the interrupt generated by the ADXL, you also need to connect the INT1 and/or INT2 pins on the ADXL to an appropriate interrupt-enabled input pin on your MCU.

The interrupt input on the MCU needs to have the following pin characteristics:

- Must have support for interrupt mode (if you want to automatically fire an interrupt service routine when the ADXL's INT pins are triggered)
- Must be configured as an input
- Must be 'attached' to an interrupt service routine, which is the function that will be called when a&nbsp; **RISING** edge is detected on the MCU's interrupt input.
- You will also need a pull down resistor on the interrupt pins

Some sample code of setting these pins up properly is shown below (assumed an **Adafruit Feather M0 Basic** , see the documentation for pin selection on other boards):

```
/** The input pins to enable the interrupt on, connected to INT1 and INT2 on the ADXL. */
#define INPUT_PIN_INT1   (5) // Uno = (2)
#define INPUT_PIN_INT2   (6) // Uno = (3)

...

/** Interrupt service routine for INT1 events. */
void int1_isr(void)
{
   /* TODO: Do something! */
}

/** Interrupt service routine for INT2 events. */
void int2_isr(void)
{
   /* TODO: Do something! */
}

...

/* Attach interrupt inputs on the MCU. */
pinMode(LED_BUILTIN, OUTPUT);
pinMode(INPUT_PIN_INT1, INPUT);
pinMode(INPUT_PIN_INT2, INPUT);
attachInterrupt(digitalPinToInterrupt(INPUT_PIN_INT1), int1_isr, RISING);
attachInterrupt(digitalPinToInterrupt(INPUT_PIN_INT2), int2_isr, RISING);
```

## Complete Example

To see how all of these pieces fit together, you can see the code for the&nbsp; **interrupts** example that is part of the standard Adafruit driver, shown below for convenience sake.

This examples enables two interrupt events on two different pins, and tracks the number of times those interrupt handlers are fired. The main loop of the program continually checks if a new interrupt event was detected, and display some details on the interrupt source when an event it detected.

https://github.com/adafruit/Adafruit_ADXL343/blob/master/examples/interrupts/interrupts.ino

# Single Tap Example

A slightly simplified example that detects single taps is shown below as well:

https://github.com/adafruit/Adafruit_ADXL343/blob/master/examples/singletap/singletap.ino

Running this&nbsp; **singletap** demo and tapping the device gently should give the following output:

![](https://cdn-learn.adafruit.com/assets/assets/000/071/815/medium800/sensors_Screenshot_2019-02-22_at_15.19.55.png?1550845280)

# Analog Devices ADXL343 Breakout Learning Guide

## Arduino API

# Analog Devices ADXL343 Breakout Learning Guide

## Python and CircuitPython

It's easy to use the ADXL343 or the ADXL345 with Python and CircuitPython, and the [Adafruit CircuitPython ADXL34x](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x) module. This module allows you to easily write Python code that reads the acceleration, taps, motion and more from the breakout.

You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python [thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

Info: 

## CircuitPython Microcontroller Wiring

First, wire up the breakout exactly as shown in the previous pages. Here is an example of wiring the ADXL343 to a Feather M0:

&nbsp;

- Connect&nbsp; **SCL** (yellow wire in STEMMA QT version) on the Feather to&nbsp; **SCL** on the ADXL343
- Connect&nbsp; **SDA** (blue wire in STEMMA QT version) on the Feather to&nbsp; **SDA** in the ADXL343
- Connect&nbsp; **GND** (black wire in STEMMA QT version) on the Feather to&nbsp; **GND** on the ADXL343
- Connect&nbsp; **3.3V** (red wire in STEMMA QT version) on the Feather to&nbsp; **VIN** on the ADXL343

![sensors_featherStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/015/medium640/sensors_featherStemma_bb.png?1647981149)

![sensors_featherBreadboard_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/016/medium640/sensors_featherBreadboard_bb.png?1647981181)

![original_sensors_ADXL343_FeatherExpress_Setup_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/017/medium640/original_sensors_ADXL343_FeatherExpress_Setup_bb.png?1647981197)

Here's an example of wiring the ADXL345 to a Feather M0:

- Connect&nbsp; **SCL** (blue wire) on the Feather to **SCL** on the ADXL345
- Connect&nbsp; **SDA** (yellow wire) on the Feather to **SDA** in the ADXL345
- Connect&nbsp; **GND** (black wire) on the Feather to **GND** on the ADXL345
- Connect&nbsp; **3.3V** (red wire) on the Feather to **VIN** on the ADXL345

![sensors_whitefeatherStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/179/medium640/sensors_whitefeatherStemma_bb.png?1648226015)

![sensors_featherBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/180/medium640/sensors_featherBB_bb.png?1648226037)

![sensors_originalADXL345_Feather_M0_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/182/medium640/sensors_originalADXL345_Feather_M0_bb.png?1648226052)

## Python Computer Wiring

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

The following shows a Raspberry Pi connected to the ADXL343:

- Connect&nbsp; **SCL** (yellow wire in STEMMA QT version) on the RPi to&nbsp; **SCL** on the ADXL343
- Connect&nbsp; **SDA** (blue wire in STEMMA QT version) on the Rpi to&nbsp; **SDA** in the ADXL343
- Connect&nbsp; **GND** (black wire in STEMMA QT version) on the Rpi to&nbsp; **GND** on the ADXL343
- Connect&nbsp; **3.3V** (red wire in STEMMA QT version) on the Rpi to&nbsp; **VIN** on the ADXL343

![sensors_piStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/018/medium640/sensors_piStemma_bb.png?1647981273)

![sensors_piBreadboard_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/019/medium640/sensors_piBreadboard_bb.png?1647981285)

![original_sensors_ADXL343_RPi3_Setup_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/020/medium640/original_sensors_ADXL343_RPi3_Setup_bb.png?1647981297)

The following shows a Raspberry Pi connected to the ADXL345:

- Connect&nbsp; **SCL** (blue wire) on the RPi to **SCL** on the ADXL345
- Connect&nbsp; **SDA** (yellow wire) on the RPi to **SDA** in the ADXL345
- Connect&nbsp; **GND** (black wire) on the RPi to **GND** on the ADXL345
- Connect&nbsp; **3.3V** (red wire) on the RPi to **VIN** on the ADXL345

![sensors_piStemma_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/183/medium640/sensors_piStemma_bb.png?1648226143)

![sensors_piBB_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/184/medium640/sensors_piBB_bb.png?1648226179)

![originalsensors_ADXL345_RasPi_I2C_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/110/185/medium640/originalsensors_ADXL345_RasPi_I2C_bb.png?1648226194)

## Library Installation

You'll need to install the [Adafruit CircuitPython ADXL34x](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x) library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://circuitpython.org/libraries).&nbsp; Our CircuitPython starter guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).

For non-express boards like the Trinket M0 or Gemma M0, you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_adxl34x.mpy**
- **adafruit\_bus\_device**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_adxl34x.mpy,&nbsp;** and **&nbsp;adafruit\_bus\_device**** &nbsp; **files and folders** &nbsp;**copied over.

Next&nbsp;[connect to the board's serial REPL&nbsp;](https://learn.adafruit.com/micropython-basics-how-to-load-micropython-on-a-board/serial-terminal)so you are at the CircuitPython&nbsp; **\>\>\>** prompt.

## Python Installation of the ADXL34x Library

You'll need to install the **Adafruit\_Blinka** library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

- `sudo pip3 install adafruit-circuitpython-adxl34x`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## CircuitPython & Python Usage

To demonstrate the usage of the breakout we'll initialize it and read the acceleration and more from the board's Python REPL.

Run the following code to import the necessary modules and create the I2C object:

```python
import time
import board
import adafruit_adxl34x

i2c = board.I2C()
```

If you're using the **ADXL343** , run the following to initialise the I2C connection with the breakout:

```python
accelerometer = adafruit_adxl34x.ADXL343(i2c)
```

If you're using the **ADXL345** , run the following to initialise the I2C connection with the breakout:

```python
accelerometer = adafruit_adxl34x.ADXL345(i2c)
```

Now you're ready to read values from and enable features of the breakout using any of the following:

- **acceleration** - The acceleration values on the x, y and z axes
- **enable\_motion\_detection** - Enables motion detection. Allows for setting threshold. Threshold defaults to 18.
- **enable\_tap\_detection** - Enables tap detection. Allows for single or double-tap detection.
- **enable\_freefall\_detection** - Enables freefall detection. Allows for setting threshold and time. Threshold defaults to 10, time defaults to 25.
- **events** - Used to read the events when motion detection, tap detection and freefall detection are enables. Requires specifying which event you are trying to read.

To print the acceleration values:

```python
while True:
    print(accelerometer.acceleration)
    time.sleep(0.2)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/176/medium800/sensors_ADXL34x_REPL_output.png?1570732642)

That's all there is to reading acceleration values from the ADXL343 and ADXL345 using CircuitPython!

## Full Example Code
https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x/blob/main/examples/adxl34x_simpletest.py

## Motion, Tap and Freefall

There are examples for enabling and using motion, tap and freefall available on GitHub:

- [Motion detection on the ADXL343 and ADXL345](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x/blob/master/examples/adxl34x_motion_detection_test.py)
- [Tap detection on the ADXL343 and ADXL345](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x/blob/master/examples/adxl34x_tap_detection_test.py)
- [Freefall detection on the ADXL343 and ADXL345](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x/blob/master/examples/adxl34x_freefall_detection_test.py)

Save any of the files as **code.py** on your CircuitPython board, or run them from the Python REPL on your Linux computer, to try them out.

# Analog Devices ADXL343 Breakout Learning Guide

## Python Docs

# Analog Devices ADXL343 Breakout Learning Guide

## Downloads

# Drivers

- CircuitPython: [Adafruit\_CircuitPython\_ADXL34x](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x)
- Arduino: [Adafruit\_ADXL343](https://github.com/adafruit/Adafruit_ADXL343)

# Design Files

The latest PCB design files (for Autodesk Eagle) can be found on Github at:

- [Adafruit\_ADXL343\_PCB](https://github.com/adafruit/Adafruit_ADXL343_PCB)
- [3D models on GitHub](https://github.com/adafruit/Adafruit_CAD_Parts/tree/main/4097%20ADXL343%20Accelerometer)

If you use Fritzing, the Fritzing object for this breakout is also available on Github at:

- [Adafruit ADXL343 Fritzing Object Original Version](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20ADXL343.fzpz)
- [Adafruit ADXL343 Fritzing Object STEMMA QT Version](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20ADXL343%20STEMMA%20QT.fzpz)

# Datasheet

You can download the datasheet for the ADXL343 via the button below:

[ADXL343 Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/070/556/original/adxl343.pdf?1549287964)
# Apps Notes

### Full-Features Pedometer Design (Analog Devices)

If you're interested in going one step further with the ADXL34x device family, you may find the following app-note from Analog Devices useful for ideas of technical tips:

[Full-Featured Pedometer Design Realized with 3-Axis Digital Accelerometer](https://cdn-learn.adafruit.com/assets/assets/000/070/557/original/pedometer-design-3-axis-digital-acceler.pdf?1549288142)
This app note details a method of performing 'step detection' with an algorithm using threshold crossing and timing intervals, and may be a useful introduction to correlating sensor data with a specific behaviour model.

# Schematic and Fab Print STEMMA QT Version
![](https://cdn-learn.adafruit.com/assets/assets/000/110/021/medium800/sensors_schem.png?1647982925)

![](https://cdn-learn.adafruit.com/assets/assets/000/110/023/medium800/sensors_fab.png?1647982991)

# Schematic and Fab Print Original Version
![](https://cdn-learn.adafruit.com/assets/assets/000/070/558/medium800/sensors_ADXL345_Schematic_REV-B.png?1549288782)

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/070/559/medium800/sensors_ADXL345_Board_REV-B.png?1549288814)


## Primary Products

### ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI

[ADXL343 - Triple-Axis Accelerometer (+-2g/4g/8g/16g) w/ I2C/SPI](https://www.adafruit.com/product/4097)
Analog Devices has followed up on their popular classic, the ADXL345, with this near-drop-in-replacement, the ADXL343. Like the original, this is a triple-axis accelerometer with digital I2C and SPI interface breakout. It has a wide sensitivity range and high resolution, operating with an 10...

In Stock
[Buy Now](https://www.adafruit.com/product/4097)
[Related Guides to the Product](https://learn.adafruit.com/products/4097/guides)

## Related Guides

- [Wireless ESP32-S2 Touch Screen Controller for Pure Data](https://learn.adafruit.com/wireless-esp32-s2-controller-for-pure-data.md)
- [Raspberry Pi I2C Clock Stretching Fixes](https://learn.adafruit.com/raspberry-pi-i2c-clock-stretching-fixes.md)
- [PyPortal Google Calendar Event Display](https://learn.adafruit.com/pyportal-google-calendar-event-display.md)
- [Adafruit FunHouse](https://learn.adafruit.com/adafruit-funhouse.md)
- [3D Printed Camera Case for MEMENTO](https://learn.adafruit.com/memento-3d-case.md)
- [Adafruit 24LC32 I2C EEPROM Breakout - 32Kbit / 4 KB](https://learn.adafruit.com/adafruit-24lc32-i2c-eeprom-breakout-32kbit-4-kb.md)
- [Adafruit RP2040 Prop-Maker Feather](https://learn.adafruit.com/adafruit-rp2040-prop-maker-feather.md)
- [Adafruit NeoDriver - I2C to NeoPixel Driver](https://learn.adafruit.com/adafruit-neodriver-i2c-to-neopixel-driver.md)
- [Using the Bluefruit Dashboard with Web Bluetooth in Chrome](https://learn.adafruit.com/bluefruit-dashboard-web-bluetooth-chrome.md)
- [Adafruit ESP32 Feather V2](https://learn.adafruit.com/adafruit-esp32-feather-v2.md)
- [Adafruit SensorLab - Gyroscope Calibration](https://learn.adafruit.com/adafruit-sensorlab-gyroscope-calibration.md)
- [Adafruit High Power Infrared LED Emitter](https://learn.adafruit.com/adafruit-high-power-infrared-led-emitter.md)
- [Sound Reactive Sunflower Baby Crib Mobile with Bluetooth Control](https://learn.adafruit.com/sound-reactive-sunflower-baby-crib-mobile-with-bluetooth-control.md)
- [Adafruit MicroSD SPI or SDIO Card Breakout Board](https://learn.adafruit.com/adafruit-microsd-spi-sdio.md)
- [Pet Bowl Water Level Sensing](https://learn.adafruit.com/pet-bowl-water-level-sensing-with-the-funhouse-and-home-assistant.md)
