Can't get magnometer data from LSM303 w/ Boron, can get Accel

I am using a Boron board that talks to a LSM303 using the adafruit sensor libraries. For some reason, I can get acceleration data, but I can't even get the magnometer to connect, but I thought they were the same device.

I am using the library: Adafruit_LSM303_U. here is my code:

Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(55555);
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(44444);
sensors_t_event event;

if (!accel.begin())
    Serial.println("Could not find accelerometer");
if (!mag.begin())
    Serial.println("Could not find magnometer");


    // /* Display the results (acceleration is measured in m/s^2) */
    Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  ");
    Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  ");
    Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");Serial.println("m/s^2 ");

    /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
    Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  ");
    Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  ");
    Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT");

in this example, the accelerometer data comes back, but it fails to find the magnometer in the mag.begin() step.

Is there some big mistake im making?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.