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

How to Use Adafruit H3LIS331 Triple-Axis Accelerometer: Examples, Pinouts, and Specs

Image of Adafruit H3LIS331 Triple-Axis AccelerometerDesign with Adafruit H3LIS331 Triple-Axis Accelerometer in Cirkit Designer

Introduction

The Adafruit H3LIS331 Triple-Axis Accelerometer is a versatile and powerful sensor capable of measuring acceleration along three axes: X, Y, and Z. This low-power, high-performance module is based on the H3LIS331DL IC from STMicroelectronics and is designed for a wide array of applications, from motion detection to dynamic orientation tracking. Its wide measurement range and adjustable sensitivity make it an excellent choice for projects ranging from robotics to sports equipment.

Explore Projects Built with Adafruit H3LIS331 Triple-Axis Accelerometer

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Teensy 4.1 Based Biometric Data Acquisition System with AD8232 Heart Rate Monitor and LIS3DH Accelerometer: A project utilizing Adafruit H3LIS331 Triple-Axis Accelerometer in a practical application
Teensy 4.1 Based Biometric Data Acquisition System with AD8232 Heart Rate Monitor and LIS3DH Accelerometer

This circuit integrates a Teensy 4.1 microcontroller with an Adafruit LIS3DH Triple-Axis Accelerometer and an AD8232 Heart Rate Monitor. The accelerometer communicates with the Teensy via I2C (SCL and SDA lines), while the heart rate monitor's output and lead-off detection (LO+ and LO-) are connected to the Teensy's analog inputs. The circuit is designed to measure both acceleration and heart rate signals, likely for a wearable or health monitoring device.

Open Project in Cirkit Designer
Image of ADXL335 Accelerometer Data Visualization with Oscilloscope: A project utilizing Adafruit H3LIS331 Triple-Axis Accelerometer in a practical application
ADXL335 Accelerometer Data Visualization with Oscilloscope

This circuit connects an AITrip ADXL335 GY-61 accelerometer to an oscilloscope for signal visualization and a 3xAA battery pack for power. The accelerometer's Z-axis output is directly monitored on the oscilloscope, allowing for real-time observation of acceleration changes along that axis. The circuit is likely used for educational or testing purposes to demonstrate how the accelerometer responds to motion.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

Pin Number Pin Name Description
1 VDD Power supply (2.16V to 3.6V)
2 GND Ground
3 SCL I2C Serial Clock Line
4 SDA I2C Serial Data Line
5 INT1 Interrupt 1 (configurable)
6 INT2 Interrupt 2 (configurable)
7 CS Chip Select for SPI (not used in I2C mode)
8 SA0 I2C Least Significant Bit of the device address

Usage Instructions

How to Use the Component in a Circuit

  1. Powering the Device: Connect the VDD pin to a power supply between 2.16V and 3.6V, and connect the GND pin to the ground of your circuit.
  2. I2C Communication: Connect the SCL and SDA pins to the corresponding I2C clock and data lines on your microcontroller, such as an Arduino UNO.
  3. Address Selection: The SA0 pin determines the least significant bit of the I2C address. Connect it to VDD or GND to select between the two possible addresses.
  4. Interrupts (Optional): The INT1 and INT2 pins can be configured to output interrupt signals for certain events. Connect these to digital pins on your microcontroller if you wish to use interrupts.

Important Considerations and Best Practices

Example Code for Arduino UNO

#include <Wire.h>

// Adafruit H3LIS331 I2C address (assuming SA0 is connected to GND)
#define ACCEL_I2C_ADDR 0x18

void setup() {
  Wire.begin(); // Initialize I2C
  Serial.begin(9600); // Start serial communication at 9600 baud

  // Configure accelerometer settings
  writeAccelRegister(0x20, 0x27); // Normal power mode, 50Hz data rate
  writeAccelRegister(0x23, 0x00); // Continuous update, LSB at lower address, ±100g
}

void loop() {
  int16_t x, y, z;

  // Read acceleration data
  x = readAccel(0x28);
  y = readAccel(0x2A);
  z = readAccel(0x2C);

  // Print the acceleration values
  Serial.print("X: ");
  Serial.print(x);
  Serial.print(" Y: ");
  Serial.print(y);
  Serial.print(" Z: ");
  Serial.println(z);

  delay(100); // Wait for 100 milliseconds
}

void writeAccelRegister(byte reg, byte value) {
  // Write a value to a register on the accelerometer
  Wire.beginTransmission(ACCEL_I2C_ADDR);
  Wire.write(reg);
  Wire.write(value);
  Wire.endTransmission();
}

int16_t readAccel(byte reg) {
  // Read a 16-bit value from a register on the accelerometer
  Wire.beginTransmission(ACCEL_I2C_ADDR);
  Wire.write(reg | 0x80); // Set auto increment bit
  Wire.endTransmission(false);
  Wire.requestFrom(ACCEL_I2C_ADDR, 2, true);

  byte lowByte = Wire.read();
  byte highByte = Wire.read();

  return (int16_t)(highByte << 8 | lowByte);
}

Troubleshooting and FAQs

Common Issues

Solutions and Tips for Troubleshooting

FAQs

Q: Can the accelerometer be used with a 5V microcontroller like the Arduino UNO? A: Yes, but ensure that the VDD pin is connected to a voltage within the specified range, and use level shifters if necessary for the I2C lines.

Q: How can I change the measurement range? A: The measurement range can be changed by writing to the CTRL_REG4 (0x23) register. Refer to the datasheet for the appropriate settings.

Q: What is the default I2C address? A: The default I2C address is 0x18 when SA0 is connected to GND, and 0x19 when SA0 is connected to VDD.