Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use Adafruit LSM303AGR: Examples, Pinouts, and Specs

Image of Adafruit LSM303AGR
Cirkit Designer LogoDesign with Adafruit LSM303AGR in Cirkit Designer

Introduction

The Adafruit LSM303AGR is a compact and versatile 6 Degrees of Freedom (6-DoF) sensor module that combines a 3-axis accelerometer and a 3-axis magnetometer. This sensor is ideal for applications requiring the measurement of both linear acceleration and magnetic fields in three dimensions. Common use cases include orientation detection, motion detection, and compass functionalities in devices such as drones, smartphones, and other portable electronics.

Explore Projects Built with Adafruit LSM303AGR

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
Image of Compass: A project utilizing Adafruit LSM303AGR in a practical application
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Teensy 4.1 Based Biometric Data Acquisition System with AD8232 Heart Rate Monitor and LIS3DH Accelerometer
Image of Teensy 4.1 accelerometer: A project utilizing Adafruit LSM303AGR in a practical application
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.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Force Measurement System with LSM303AGR Sensor
Image of final circuit diagram: A project utilizing Adafruit LSM303AGR in a practical application
This circuit features an Adafruit HUZZAH32 ESP32 Feather microcontroller connected to an Adafruit LSM303AGR sensor via I2C communication lines (SCL and SDA), a force sensing resistor (FSR) interfaced through an analog input with a pull-up resistor, and powered by a 3xAA battery pack. The LSM303AGR sensor provides acceleration and magnetic field measurements, while the FSR detects applied force. The ESP32 processes these inputs and can be programmed to respond to sensor data for applications such as motion tracking and force measurement.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO R4 WiFi and Adafruit LIS3DH Accelerometer-Based Motion Detection System
Image of circuit: A project utilizing Adafruit LSM303AGR in a practical application
This circuit consists of an Arduino UNO R4 WiFi connected to an Adafruit LIS3DH Triple-Axis Accelerometer via I2C communication. The Arduino reads acceleration data from the LIS3DH sensor and outputs it to the serial monitor for further analysis or processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with Adafruit LSM303AGR

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 Compass: A project utilizing Adafruit LSM303AGR in a practical application
Arduino Ethernet with LSM303DLHC Accelerometer and Compass Interface
This circuit connects an Adafruit LSM303DLHC Triple-axis Accelerometer+Magnetometer (Compass) to an Arduino Board Ethernet using I2C communication protocol. The SCL and SDA pins of the sensor are connected to the A5 and A4 pins of the Arduino, respectively, for serial clock and data transfer. The sensor is powered by the Arduino's 5V output, and both devices share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Teensy 4.1 accelerometer: A project utilizing Adafruit LSM303AGR 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.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of final circuit diagram: A project utilizing Adafruit LSM303AGR in a practical application
ESP32-Based Force Measurement System with LSM303AGR Sensor
This circuit features an Adafruit HUZZAH32 ESP32 Feather microcontroller connected to an Adafruit LSM303AGR sensor via I2C communication lines (SCL and SDA), a force sensing resistor (FSR) interfaced through an analog input with a pull-up resistor, and powered by a 3xAA battery pack. The LSM303AGR sensor provides acceleration and magnetic field measurements, while the FSR detects applied force. The ESP32 processes these inputs and can be programmed to respond to sensor data for applications such as motion tracking and force measurement.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of circuit: A project utilizing Adafruit LSM303AGR in a practical application
Arduino UNO R4 WiFi and Adafruit LIS3DH Accelerometer-Based Motion Detection System
This circuit consists of an Arduino UNO R4 WiFi connected to an Adafruit LIS3DH Triple-Axis Accelerometer via I2C communication. The Arduino reads acceleration data from the LIS3DH sensor and outputs it to the serial monitor for further analysis or processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

General Features

  • 3-axis digital linear acceleration sensor
  • 3-axis digital magnetic sensor
  • Acceleration range: ±2/±4/±8/±16 g
  • Magnetic range: ±50 gauss
  • 16-bit data output
  • I2C serial interface
  • Operating Voltage: 2.5V to 5.5V

Pin Configuration and Descriptions

Pin Number Pin Name Description
1 VIN Power supply (2.5V to 5.5V)
2 3Vo 3.3V output from the voltage regulator
3 GND Ground
4 SDA I2C data line
5 SCL I2C clock line
6 DRDY Data ready output signal (optional)

Usage Instructions

Integration with a Circuit

To use the LSM303AGR in a circuit, connect the VIN pin to a power supply between 2.5V and 5.5V, and the GND pin to the ground. The SDA and SCL pins should be connected to the I2C data and clock lines, respectively. If you wish to use the Data Ready (DRDY) feature, connect the DRDY pin to a digital input on your microcontroller.

Best Practices

  • Ensure that the power supply is stable and within the specified voltage range.
  • Use pull-up resistors on the I2C lines if they are not already present on the microcontroller board.
  • Place the sensor away from magnetic fields that may interfere with the magnetometer readings.
  • Calibrate the magnetometer in the application's environment for accurate readings.

Example Code for Arduino UNO

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

/* Create an instance of the LSM303 accelerometer and magnetometer sensor */
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321);
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(12345);

void setup(void) {
  Serial.begin(9600);
  Serial.println("LSM303AGR Test");

  /* Initialize the accelerometer */
  if (!accel.begin()) {
    Serial.println("No accelerometer detected");
    while (1);
  }

  /* Initialize the magnetometer */
  if (!mag.begin()) {
    Serial.println("No magnetometer detected");
    while (1);
  }
}

void loop(void) {
  /* Get a new sensor event */
  sensors_event_t event;

  /* Read the accelerometer */
  accel.getEvent(&event);
  Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" m/s^2 ");
  Serial.println("");

  /* Read the magnetometer */
  mag.getEvent(&event);
  Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print(" uT ");
  Serial.println("");

  /* Delay before the next reading */
  delay(500);
}

Troubleshooting and FAQs

Common Issues

  • Sensor not detected: Ensure that the wiring is correct and that the sensor is properly powered.
  • Inaccurate readings: Calibrate the sensor in your specific environment, as magnetic fields can vary.
  • No data on I2C: Check for proper pull-up resistors and that no other device is conflicting on the I2C bus.

FAQs

Q: Can the LSM303AGR be used with a 3.3V system? A: Yes, the sensor can operate at 3.3V, and it includes a 3.3V regulator which can be used to power the sensor when supplied with higher voltages.

Q: How do I calibrate the magnetometer? A: Calibration typically involves rotating the sensor in several orientations and using software to determine and compensate for biases.

Q: What is the purpose of the DRDY pin? A: The Data Ready (DRDY) pin is an optional feature that signals when new data is available to read, which can be useful for synchronizing sensor readings.

For further assistance, consult the Adafruit LSM303AGR datasheet and the Adafruit Sensor library documentation.