Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use ADXL343 I2C/SPI - STEMMA QT / Qwiic: Examples, Pinouts, and Specs

Image of ADXL343 I2C/SPI - STEMMA QT / QwiicDesign with ADXL343 I2C/SPI - STEMMA QT / Qwiic in Cirkit Designer

Introduction

The ADXL343 is a low-power, 3-axis accelerometer manufactured by Adafruit, designed for motion sensing applications. It features a compact form factor and supports both I2C and SPI communication protocols, making it versatile and easy to integrate into a wide range of projects. With STEMMA QT / Qwiic connectors, the ADXL343 simplifies wiring and enables quick prototyping without soldering.

Explore Projects Built with ADXL343 I2C/SPI - STEMMA QT / Qwiic

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Common Applications

Technical Specifications

The ADXL343 offers a range of features and specifications that make it suitable for various motion sensing applications.

Key Specifications

Parameter Value
Operating Voltage 3.3V (STEMMA QT / Qwiic compatible)
Communication Protocols I2C, SPI
Measurement Range ±2g, ±4g, ±8g, ±16g (configurable)
Resolution 10-bit or 13-bit
Output Data Rate (ODR) 0.1 Hz to 3200 Hz
Operating Temperature -40°C to +85°C
Power Consumption 23 µA in measurement mode (typical)
Dimensions 25.4mm x 17.8mm x 4.6mm

Pin Configuration

The ADXL343 breakout board includes the following pins:

Pin Name Description
VIN Power input (3.3V or 5V compatible)
GND Ground connection
SDA I2C data line (also used for SPI MOSI in SPI mode)
SCL I2C clock line (also used for SPI SCK in SPI mode)
CS Chip Select (used in SPI mode; tie to GND for I2C mode)
INT1 Interrupt 1 output (configurable for motion detection, free-fall, etc.)
INT2 Interrupt 2 output (configurable for additional interrupt functionality)

Usage Instructions

The ADXL343 can be used in either I2C or SPI mode, depending on your project requirements. Below are the steps to integrate and use the ADXL343 in a circuit.

Connecting the ADXL343

  1. I2C Mode:

    • Connect VIN to a 3.3V or 5V power source.
    • Connect GND to the ground of your circuit.
    • Connect SDA to the I2C data pin on your microcontroller (e.g., Arduino UNO A4).
    • Connect SCL to the I2C clock pin on your microcontroller (e.g., Arduino UNO A5).
    • Tie the CS pin to GND to enable I2C mode.
  2. SPI Mode:

    • Connect VIN and GND as described above.
    • Connect SDA to the SPI MOSI pin on your microcontroller.
    • Connect SCL to the SPI SCK pin on your microcontroller.
    • Connect CS to a digital pin on your microcontroller to act as the chip select.
    • Optionally, connect INT1 and INT2 to monitor interrupts.

Arduino Example Code (I2C Mode)

Below is an example of how to use the ADXL343 with an Arduino UNO in I2C mode. This code uses the Adafruit ADXL343 library, which can be installed via the Arduino Library Manager.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL343.h>

// Create an ADXL343 object
Adafruit_ADXL343 adxl = Adafruit_ADXL343(12345); // Pass an arbitrary sensor ID

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10); // Wait for Serial Monitor to open

  // Initialize the ADXL343
  if (!adxl.begin()) {
    Serial.println("Failed to find ADXL343 chip. Check wiring!");
    while (1);
  }
  Serial.println("ADXL343 found!");

  // Set measurement range to ±4g
  adxl.setRange(ADXL343_RANGE_4_G);
  Serial.print("Range set to: ");
  switch (adxl.getRange()) {
    case ADXL343_RANGE_2_G: Serial.println("±2g"); break;
    case ADXL343_RANGE_4_G: Serial.println("±4g"); break;
    case ADXL343_RANGE_8_G: Serial.println("±8g"); break;
    case ADXL343_RANGE_16_G: Serial.println("±16g"); break;
  }
}

void loop() {
  // Read acceleration data
  sensors_event_t event;
  adxl.getEvent(&event);

  // Print acceleration values
  Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" m/s^2 ");
  Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" m/s^2 ");
  Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.println(" m/s^2");

  delay(500); // Delay for readability
}

Best Practices

Troubleshooting and FAQs

Common Issues

  1. ADXL343 not detected:

    • Verify the wiring, especially the SDA and SCL connections.
    • Ensure the CS pin is tied to GND for I2C mode.
    • Check that the correct I2C address (default: 0x53) is being used.
  2. Incorrect or unstable readings:

    • Ensure the sensor is securely mounted to avoid mechanical noise.
    • Verify the power supply voltage is stable and within the specified range.
  3. Interrupts not triggering:

    • Double-check the interrupt configuration in your code.
    • Ensure the INT1 or INT2 pins are connected to the correct microcontroller pins.

FAQs

Q: Can I use the ADXL343 with a 5V microcontroller?
A: Yes, the ADXL343 breakout board includes level-shifting circuitry, making it compatible with both 3.3V and 5V systems.

Q: How do I change the measurement range?
A: Use the setRange() function in the Adafruit ADXL343 library to configure the range (e.g., ±2g, ±4g, etc.).

Q: What is the default I2C address of the ADXL343?
A: The default I2C address is 0x53. If there are address conflicts, you can modify the address by adjusting the ALT ADDRESS pin on the breakout board.

Q: Can I use both I2C and SPI simultaneously?
A: No, the ADXL343 operates in either I2C or SPI mode, but not both at the same time. Select the mode by configuring the CS pin.

By following this documentation, you can successfully integrate and use the ADXL343 in your projects!