

The LSM303C is a 6 Degrees of Freedom (6 DOF) sensor manufactured by SparkFun (Part ID: SEN-13303). It integrates a 3-axis accelerometer and a 3-axis magnetometer into a single compact package, enabling precise motion and orientation detection in three-dimensional space. This sensor is ideal for applications requiring motion tracking, navigation, and orientation sensing, such as robotics, drones, augmented reality devices, and mobile electronics.
The LSM303C communicates via I²C or SPI interfaces, making it compatible with a wide range of microcontrollers, including Arduino boards. Its small size and low power consumption make it suitable for portable and embedded systems.








Below are the key technical details of the LSM303C sensor:
The LSM303C sensor has 12 pins. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | VDD | Power supply (1.8V to 3.6V) |
| 2 | GND | Ground |
| 3 | SCL/SPC | I²C clock line (SCL) or SPI clock line (SPC) |
| 4 | SDA/SDI/SDO | I²C data line (SDA) or SPI data input/output (SDI/SDO) |
| 5 | CS | SPI chip select (active low). Tie to VDD for I²C mode. |
| 6 | INT1 | Interrupt 1 output (configurable) |
| 7 | INT2 | Interrupt 2 output (configurable) |
| 8-12 | NC | Not connected (leave floating or connect to GND for stability) |
The LSM303C can be easily interfaced with an Arduino UNO using the I²C protocol. Below is the wiring guide:
| LSM303C Pin | Arduino UNO Pin |
|---|---|
| VDD | 3.3V |
| GND | GND |
| SCL | A5 (SCL) |
| SDA | A4 (SDA) |
| CS | Connect to VDD |
The following example demonstrates how to read accelerometer and magnetometer data from the LSM303C using the SparkFun LSM303C library.
#include <Wire.h>
#include <SparkFunLSM303C.h>
// Create LSM303C object
LSM303C myIMU;
void setup() {
Serial.begin(9600); // Initialize serial communication
Wire.begin(); // Initialize I²C communication
// Initialize the LSM303C sensor
if (myIMU.begin() != 0) {
Serial.println("Failed to initialize LSM303C!");
while (1); // Halt execution if initialization fails
}
Serial.println("LSM303C initialized successfully.");
}
void loop() {
// Read accelerometer data
float accelX = myIMU.readAccelX();
float accelY = myIMU.readAccelY();
float accelZ = myIMU.readAccelZ();
// Read magnetometer data
float magX = myIMU.readMagX();
float magY = myIMU.readMagY();
float magZ = myIMU.readMagZ();
// Print accelerometer data
Serial.print("Accel (g): X=");
Serial.print(accelX, 2);
Serial.print(", Y=");
Serial.print(accelY, 2);
Serial.print(", Z=");
Serial.println(accelZ, 2);
// Print magnetometer data
Serial.print("Mag (gauss): X=");
Serial.print(magX, 2);
Serial.print(", Y=");
Serial.print(magY, 2);
Serial.print(", Z=");
Serial.println(magZ, 2);
delay(500); // Wait 500ms before the next reading
}
Sensor Not Detected:
Incorrect or No Data:
Noise in Readings:
Q1: Can the LSM303C be used with a 5V microcontroller?
A1: Yes, but you must use a logic level shifter to step down the 5V signals to 3.3V for the sensor.
Q2: How do I switch between I²C and SPI modes?
A2: To use I²C mode, connect the CS pin to VDD. For SPI mode, connect the CS pin to the microcontroller and configure it as a chip select line.
Q3: What is the maximum cable length for I²C communication?
A3: The maximum cable length depends on the pull-up resistor values and the I²C clock speed. For standard 100 kHz I²C, a length of up to 1 meter is typically reliable.
By following this documentation, you can effectively integrate the LSM303C sensor into your projects for accurate motion and orientation sensing.