Adafruit LSM303D with SPARKFUN LSM9DS1

Hello Folks,

I want to interface Adafruit LSM303DLHC (Accelerometer + Magnetometer) with SPARKFUN 9dof LSM9DS1(ACC+ Mag+Gyro) in I2C with arduino Mega.

i2c address i used : adafruit Acc 12345
Mag 54321
Sparkfun Acc/Gyro 0x6B
Magnetometer 0x1E

I can run individually and both sensor working properly but when i connect together, i can't run both sensors. If i get adafruit sensor all readings at that time Mag values will be zero if i connect the sparkfun sensor.
Same thing, when i connect sparkfun 1st and connect adafruit sensor 2nd then, my sparkfun magnetic readings will be zero.
In sort, i can't use both magnetometer together.
I can't figure it out.
Thank you in advance.

I am using predefined libraries from adafruit and sparkfun.

12345 is not an I2C address, nor is 54321.

12345 is not an I2C address, nor is 54321.

But, it is giving the right data when i use only Adafruit Sensor.

Thank you.

How fascinating!

I m sorry, I saw the library for both sensor.
So, for Adafruit LSM303D from header file

#define LSM303_ADDRESS_ACCEL (0x32 >> 1) // 0011001x
#define LSM303_ADDRESS_MAG (0x3C >> 1) // 0011110x

This is from sparkfun LSM9D header file

#define LSM9DS1_M 0x1E // Would be 0x1C if SDO_M is LOW
#define LSM9DS1_AG 0x6B // Would be 0x6A if SDO_AG is LOW

mentioned here: SparkFun_LSM9DS1_Arduino_Library/LSM9DS1_Basic_I2C.ino at master · sparkfun/SparkFun_LSM9DS1_Arduino_Library · GitHub

Thank you

PS. I noted while checking with sensors, if i connect more than 2 sensors on I2C then, 3rd sensor is not working. I checked with different combination of the sensors.

I hope it helps to solve my issue.

Do you have the required pullup resistors on SDA and SCL? If not, add them. If so, you may need to reduce their value to 2.2K or so.

(Often but not always, 10K or 4.7K resistors are already in place. You can add 4.7K resistors in parallel to the existing ones, between Vcc and each pin).