Page 1 of 12
LSM303C 6DoF Hookup Guide
Introduction
The LSM303C is a 6
degrees of freedom
(6DOF)
inertial measurement unit
(IMU) in a sigle package. It houses a 3-axis accelerometer, and a 3-axis
magnetometer. The range of each sensor is configurable: the
accelerometer’s scale can be set to ±2g, ±4g, ±6g, or ±8g, and the
magnetometer has full-scale range of ±16 gauss.
LSM303C Breakout Board
The LSM303C supports I
2
C and SPI. This tutorial focuses on using this
device in I
2
C mode, but will briefly describe how to use SPI.
Covered In This Tutorial
First we’ll introduce you to the breakout board. Then we’ll switch over to
example code and show you how to interface with the board using an
Arduino and our SparkFun LSM303C 6 DOF IMU Breakout Arduino Library.
The tutorial is split into the following sections:
• Breakout Board Overview – This page examines the LSM303C
Breakout Board – topics like the pinout, jumpers, and schematic are
covered.
• Hardware Assembly – How to assemble the hardware to run some
example code.
• Installing the Arduino Library – How to install the Arduino library, and
use a simple example sketch to verify that your hookup works.
• Resources & Going Further – Resources for learning and doing more
with the LSM303C.
Required Materials
This tutorial explains how to use the LSM303C Breakout Board with an
Page 2 of 12
Arduino. To follow along, you’ll need the following materials:
SparkFun LSM303C Hookup Guide
SparkFun Wish List
SparkFun 6 Degrees of Freedom Breakout - LSM303C
BOB-13303
The LSM303C is a 6 Degrees of Freedom (6DOF) inertial measurem…
Jumper Wires Standard 7" M/M Pack of 30
PRT-11026
If you need to knock up a quick prototype there's nothing like having a…
Breadboard - Self-Adhesive (White)
PRT-12002
This is your tried and true white solderless breadboard. It has 2 power…
Break Away Headers - Straight
PRT-00116
A row of headers - break to fit. 40 pins that can be cut to any size. Us…
Arduino Pro Mini 328 - 3.3V/8MHz
DEV-11114
It's blue! It's thin! It's the Arduino Pro Mini! SparkFun's minimal design…
The LSM303C is a 2.5V device!
Supplying voltages greater than 4.8V
can permanently damage the IC. InvenSense recommends running
from
1.9V to 3.6V.
As long as your Arduino has a 3.3V supply output,
you shouldn't need any extra level shifting. See our [logic level tutorial]
(tutorials/62) for more info if you aren't using a 3.3V system.
Suggested Reading
If you’re not familiar with some of the concepts below, we recommend
checking out that tutorial before continuing on.
• Pull-up Resistors
• Accelerometer Basics
• Inter-Integrated Circuit Communication (I
2
C)
Hardware Overview
The Pinout
The LSM303C 6 DOF Breakout has 10 plated through hole connections.
Top View of LSM303C Breakout Board
The following table summarizes all of the plated through hole connections
Page 3 of 12
on the breakout board:
Pin Label
GND
VDD_IO
Pin Function
Ground reference
Power supply for
I/O pins
I
2
C serial data
SPI serial data
input
3-wire interface
serial data output
I
2
C serial clock
SPI serial port clock
Accelerometer
interrupt signal
Notes
+0V
1.71V up to VDD + 0.1V
SDA/
SDI/
SDO
ST calls the second serial interface
SPI, but it's really a half-duplex
variant that uses the same pin for
MISO and for MOSI. Note that all 3
data signals are the same pin.
100 or 400 kHz I
2
C
Up to 10 MHz SPI
The functions, the threshold and the
timing of this interrupt are
configurable.
Configurable output to indicate when
accelerometer or magnetometer data
is ready.
1: SPI idle mode / I2C communication
enabled;
0: SPI communication mode / I
2
C
disabled
1.9V to 3.6V
1: SPI idle mode / I2C communication
enabled;
0: SPI communication mode / I2C
disabled
The functions, the threshold and the
timing of this interrupt are
configurable.
SCL/
SCLK
INT_XL
DRDY
Data ready
CS_XL
Accelerometer: SPI
enable
I
2
C/SPI mode
selection
Power supply
Magnetometer: SPI
enable
I
2
C/SPI mode
selection
Magnetometer
interrupt signal
VDD
CS_MAG
INT_MAG
Power Supply
The LSM303C breakout has three power supply plated thru-hole
connections: a 0V reference (GND), a core supply (VDD), and an IO supply
(VDD_IO). The core of the IC can be powered from
1.9-3.6V.
The IO must
be given a potential of at least 1.71V up to the core supply voltage plus
0.1V. This dual supply setup eliminates the need for external voltage level
translation. A 3.3V rail can power most of the device while still being able to
communicate with a 1.8V processor without drawing all of its power from
that lower voltage rail.
Communication
The LSM303C communicates over I
2
C or ‘SPI’ using the same plated thru-
hole connections. The implementation of ‘SPI’ on the LSM303C isn’t
standard; it’s a half-duplex variant. Standard SPI has a MOSI and a MISO
signal. Both of these are found on the single SDA/SDI/SDO connection.
The more common Arduino variants don’t have hardware that directly
supports this, so we are bit banging in our library. Your system may be
compatible, so we didn’t add external components to get the hardware to
Page 4 of 12
work with the Atmel SPI hardware. This connection is also used as the SDA
connection for I
2
C. Testing showed that the implementation of this IO acts
like an open-drain like is common with I
2
C. This means that a pull-up
resistor is needed for both SPI and I
2
C. The breakout includes this pull-up.
Both communication modes share the same clock line (SCL/SCLK).
The LSM303C is implemented as two separate cores on the same die. The
accelerometer and magnetometer have their own chip select lines. In I
2
C
mode, they have their own unique addresses. The accelerometer is at
0x1D,
and the magnetometer is at
0x1E.
Interrupts
There are a variety of interrupts on the LSM303C. The system can be
configured to generate an interrupt signal for free-fall, motion detection and
magnetic field detection. The actual function of the two interrupt pins
(INT_XL & INT_MAG) are highly configurable through either the I
2
C or SPI
interfaces. They can be active high or low, latching or non-latching, etc.
This advanced topic won’t be covered in this hookup guide. Please
reference the datasheet for more information.
The Jumper
In many cases, especially Arduino related, you won’t have multiple lower
voltage rails. For these cases we’ve included SJ2. Your board comes with
this jumper closed with a trace by default. This connects VDD_IO and VDD.
Closeup of voltage jumper
The intention of this jumper is to allow the end user to power use the board
and begin developing right out of the box. To disable any of these jumpers,
whip out your handy hobby knife, and carefully cut the small traces between
the two pads. You may then connect VDD_IO to whatever power rial you
desire.
Hardware Assembly
I
2
C Example
The basic use case for the LSM303C requires 4 connections to the
µController or µProcessor; power, ground, I
2
C clock and data. The following
images shows how we used a SparkFun FTDI Basic Breakout, and an 3.3V
Arduino Pro Mini to power and interface to a LSM303C 6 DOF Breakout
board.
Page 5 of 12
An LSM303C wired up to and Arduino Pro Mini for the MinimalistExample
(IIC)
Make connections to the breakout anyway that makes you happy. The
board in the above photo has a straight header soldered to it. We could
have used a right angle header, or wire, etc.
Please note that different
mounting orientations will alter the orientation of the axes.
Make sure
your code matches the physical orientation for your projects.
For this demo, we made the following connections:
Arduino Pro Mini
VCC
GND
SDA
LSM303C Breakout
VDD
GND
SDA/SDI/SDO
Notes
+3.3V
+0V
Serial data @ +3.3V CMOS
logic
Serial clock @ +3.3V CMOS
logic
SCL
SCL/SCLK
The whole system in our testing was powered via USB through the FTDI
basic.
Electrical connections for demo
SPI Example