Pololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C main
Pololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C with coinPololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C in bagPololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C in hand backsidePololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C in hand

Pololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C

$15.95

The combination of a 3 Axis Accelerometer and 3 Axis Magnetometer (3D compass) makes for an amazing navigation tool (perfect for use along with our Gyro sensors). This sensor allows you to measure and calculate force vectors along with measuring magnetic fields, and finding where north is when used as a compass.

This makes for an excellent tool to determine both the azimuth (direction of pointing) and elevation (angle above the ground) of your project, and adds a ton of new possibilities to your projects. All in all an excellent sensor for use with a number of microcontrollers including the Arduino/Versalino platforms.

Quantity discounts available
1-910-99100+
$15.95$14.36$13.56

Out of stock

Product Description

Package Contents:

Pololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C

Features/Specifications:

Interface: I²C, SPI (one 16-bit reading per axis on each device)
Minimum operating voltage: 2.5 V
Maximum operating voltage: 5.5 V
Measurement range: ±2, ±4, ±6, ±8, or ±16 g (accelerometer)
±2, ±4, ±8, or ±12 gauss (magnetometer)3
Supply current: 5 mA

(Usage information and diagrams provided by Pololu)

Usage diagram:

LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator pinout

Pinout

PINDescription
VDDRegulated 3.3 V output. Almost 150 mA is available to power external components. (If you want to bypass the internal regulator, you can instead use this pin as a 3.3 V input with VIN disconnected.)
VINThis is the main 2.5 V to 5.5 V power supply connection. The SCL/SPC and SDA/SDI level shifters pull the I²C and SPI bus high bits up to this level.
GNDThe ground (0 V) connection for your power supply. Your I²C or SPI control source must also share a common ground with this board.
SDA/SDI/SDOLevel-shifted I²C data line and SPI data in line (also doubles as SDO in 3-wire mode): HIGH is VIN, LOW is 0 V
SCL/SPCLevel-shifted I²C/SPI clock line: HIGH is VIN, LOW is 0 V
SDO/SA0SPI data out line in 4-wire mode: HIGH is VDD, LOW is 0 V. This output is not level-shifted. Also used as an input to determine I²C slave address (see below).
CSSPI enable (chip select). Pulled up to VDD to enable I²C communication by default; drive low to begin SPI communication.
INT2Programmable interrupt, a 3.3-V-logic-level output. This output is not level-shifted.
INT1Programmable interrupt, a 3.3-V-logic-level output. This output is not level-shifted.

 

I²C Communication

With the CS pin in its default state (pulled up to VDD), the LSM303D can be configured and its readings can be queried through the I²C bus. Level shifters on the I²C clock (SCL) and data lines (SDA) enable I²C communication with microcontrollers operating at the same voltage as VIN (2.5–5.5V). A detailed explanation of the protocol can be found in the LSM303D datasheet (1MB pdf), and more detailed information about I²C in general can be found in NXP’s I²C-bus specification (371k pdf).

In I²C mode, the sensor’s 7-bit slave address has its two least significant bits determined by the voltage on the SA0 pin. The carrier board pulls SA0 to VDD through a 4.7 kΩ resistor, making the least significant bits 01 and setting the slave address to 0011101b by default. If the selected slave address happens to conflict with some other device on your I²C bus, or if you want to use two LSM303D sensors on the same bus, you can drive SA0 low to set the least significant bits to 10 (which sets the slave address to 0011110b).

The I²C interface on the LSM303D is compliant with the I²C fast mode (400 kHz) standard. In our tests of the board, we were able to communicate with the chip at clock frequencies up to 400 kHz; higher frequencies might work but were not tested.

SPI Communication

To communicate with the LSM303D in SPI mode, the CS pin (which the board pulls to VDD through a 4.7 kΩ resistor) must be driven low before the start of an SPI command and allowed to return high after the end of the command. Level shifters on the SPI clock (SPC) and data in (SDI) lines enable SPI communication with microcontrollers operating at the same voltage as VIN (2.5 V to 5.5 V).

In the default 4-wire mode, the sensor transmits data to the SPI master on a dedicated data out (SDO) line that is not level-shifted. If the SPI interface is configured to use 3-wire mode instead, the SDI line doubles as SDO and is driven by the LSM303D when it transmits data to the master. A detailed explanation of the SPI interface on the LSM303D can be found in itsdatasheet (1MB pdf).

Sample Code

We have written a basic Arduino library for this LSM303 carrier board that makes it easy to interface this sensor with an Arduino. The library makes it simple to read the raw accelerometer and magnetometer data, and it has a function for computing the tilt-compensated heading for those looking to use this sensor as a tilt-compensated compass.

Protocol Hints

The datasheet provides all the information you need to use this sensor, but picking out the important details can take some time. Here are some pointers for communicating with and configuring the LSM303D that we hope will get you up and running a little bit faster:

  • The magnetometer and accelerometer are in power-down mode by default. You have to turn them on by writing the appropriate values to the CTRL1 and CTRL7 registers.
  • You can read or write multiple registers in a single I²C command by asserting the most significant bit of the register address to enable address auto-increment.
  • You can enable the same auto-increment feature in SPI mode by asserting the second bit (bit 1, called the MS bit in the datasheet) of an SPI command.
  • Compared with previous LSM303-series sensors, the register interface to the magnetometer in the LSM303D is much more consistent with the accelerometer interface, and its accelerometer and magnetometer share a common I²C address instead of acting as two separate slave devices on the same bus.

Reviews

There are no reviews yet.

Be the first to review “Pololu LSM303D 3D Compass and Accelerometer Carrier with Voltage Regulator SPI & I2C”

SKU: 615872422692 Categories: , Brands: .