There are now two Adafruit made LSM303 breakouts! Schnikes! They are nearly identical in function but different enough that they require different drivers for the magnetometer. Why only the magnetometer? Well, I'm gonna let you in on a little secret: the LSM303 is two sensors stuck in the same box!
Because both packages have the same accelerometer sensor with the same register layout, we can use the same accelerometer driver for both. The magnetometers despite both having the same I2C address (0x1E), have completely different register layouts which means they each need their own driver library.
So, you're going to need to know which version you have. Here is a highly scientific way of telling the two Adafruit breakouts apart:
The LSM303AGR IS BLACK AND SAYS "LSM303AGR" unlike the
LSM303DLHC WHICH IS BLUE AND SAYS "LSM303DLHC"
Complex, I know, but I believe in you. There are more subtle differences outlined below
The new kid on the adafruit block is the LSM303AGR. It's an update to the LSM303 series that is much smaller and has a different magnetometer chip inside. Our breakout looks like this:
In addition to being a physically smaller and easier to lose chip, there are a few other difference as well. The chip itself exposes an interrupt pin for the magnetometer (INTM) (perhaps a feature of the new magnetometer sensor inside?) as well as chip select pins for both the accelerometer and magnetometer (CSA and CSM respectively).
Another exciting difference between the two is the addition of two STEMMA QT connectors, one on each side of the board. This allows you to use the sensor without needing to solder as well as being able to chain it with other STEMMA QT sensors.
The older, or perhaps more seasoned AdafruitLSM303 breakout uses the LSM303DLHC and looks like this:
Compared to the LSM303AGR, you can see that the sensor itself (the black rectangle in the center) is physically larger. Additionally the pins are in a different order and the LSM303DLH exposes a DRDY (data ready) pin.