Description
What it is
The SLM303DLH is an electronic module that integrates both the accelerometer and the magnetometer into a single unit, providing data on position, inclination, and direction. This component is designed to be used with Arduino or other microcontrollers.
Features
- 3-axis module with accelerometer and magnetometer
- Perfect for gyroscope and motion projects
What it is for
The SLM303DLH is ideal for applications that require the measurement of position, inclination, or direction. It can be used in robotics, drone, and other spatial orientation systems projects. It is compatible with Arduino and ESP32.
Tutorial: How to use LSM303DLH Accelerometer Magnetometer
The SLM303DLH is a sensor module that combines both the accelerometer and the magnetometer in a single unit. This component is ideal for electronic and robotics projects where measuring position, inclination, or direction is required.
What you need
- Arduino Uno
- USB Type B cable
- Arduino IDE software
Steps
- Connect the LSM303DLH module to the Arduino pin SDA and SDL using an I2C cable.
- Open the Arduino IDE and install the Adafruit_LSM303 library. Check the datasheet for specific connection details.
- Upload the example sketch provided by the library or write a new one following the datasheet instructions.
- Check that the Arduino indicator LED turns on and off, confirming correct communication between the Arduino and the module.
- Monitor the data through the Arduino IDE serial console to see how they change based on the module’s position.
- Modify the sketch to adapt it to the specific needs of your project.
Example code
// Includi la libreria
#include <Adafruit_LSM303.h>
// Crea un oggetto LSM303
Adafruit_LSM303_Accel lsm = Adafruit_LSM303_Accel(52000);
void setup() {
Serial.begin(9600);
}
void loop() {
if(!lsm.read()) return;
int16_t ax, ay, az;
lsm.getAccel(&ax, &ay, &az);
Serial.print(ax); Serial.print(", ");
Serial.print(ay); Serial.print(", ");
Serial.println(az);
}
Mini project
Create a small gyroscope that indicates direction with an LED arrow. Use the LSM303DLH module to detect inclination and direction, then control the LEDs based on the received data.
Common mistakes
- I2C connection problems
- Library installation error
- Inconsistent or incorrect data
Recommended accessories
- Arduino Uno R3
- Adafruit_LSM303 library
- Breadboard
- RGB LED
Frequently asked questions
How can I access the module’s data?
Use the Adafruit_LSM303 library to read accelerometer and magnetometer values.
What projects can be made with this module?
You can create a gyroscope, a digital compass, or an indoor positioning system.









Reviews
There are no reviews yet.