The LSM303 breakout board combines a magnetometer/compass module with a triple-axis accelerometer to make a compact navigation subsystem. The I2C interface is compatible with both 3.3v and 5v processors and the two pins can be shared by other I2C devices. Combined with a 3-axis gyro such as the L3GD20, you have all the sensors you need for a complete IMU (Inertial Measurement Unit) for use in aerial, terrestrial or marine navigation.
In this tutorial we will show you how to connect the LSM303 to an Arduino, CircuitPython board, or Blinka supported device, and how to use it to measure orientation relative to the earth's magnetic field, and acceleration in three axis.
One great feature of the newer LSM303AGR is that it includes a STEMMA QT connectors that allow you to use it without soldering. Just plug in a STEMMA QT to male header cable to connect it to a breadboard or development board with female headers and you're off to the races! You can even chain it with other STEMMA QT breakouts using a STEMMA QT cable
The sensor consists of micro-machined structures on a silicon wafer. There are structures designed to measure acceleration and magnetic fields in the X, Y and Z axis
These structures are suspended by polysilicon springs which allow them to deflect when subject to acceleration in the X, Y and/or Z axis. Deflection causes a change in capacitance between fixed plates and plates attached to the suspended structure. This change in capacitance on each axis is converted to an output voltage proportional to the acceleration on that axis.
These structures are similar to the accelerometer structures, but are etched with microscopic coils. An excitation current is passed through the coils, and the Lorentz Force due to the magnetic field causes the structure to deflect. Once again the deflection is converted to an output voltage proportional to the strength of the magnetic field in that axis.