Adafruit 9dof LSM9DS0 library was working. Now causes cloud disconnect?

I am using an adafruit flora lsm9ds0 with the adafruit_lsm9ds0 library over I2C.
I had the default sensorapi.ino working 2 weeks ago. I could see all the data in a monitor working great.
Today is now the first time I have touched my project, and every-time I try to flash the sketch, it’s successful for a second, then the monitor prints “LSM9DS0 9DOF Sensor Test”, and then I get the breathing green “disconnected from cloud” led.
I guess it is getting hung up somewhere, but I’m going crazy trying to figure it out.

Other sketches still seem to work fine.

I originally refrenced this thread:
And had it working.

The code verifies. I have flashed from safe mode, I have re-connected the photon to the network, I just can’t figure it out. It was working great, and nothing I can figure out has changed.
Even when I just flash the bare photon, without the lsm9ds0 connected, the monitor doesn’t get to the next line “Ooops, no LSM9DS0 detected … Check your wiring or I2C ADDR!” when lsm.begin() fails - so I just don’t get it.

I’m using the web ide, and firmware 0.61 on a particle photon. I’m on windows, and other sketches are working…

Any idea how I can troubleshoot this? Im going a bit crazy.

To prevent the breathing green you need to unblock your code.
A common mistake is this


This should rather be

    while(1) Particle.process();

in order to keep servicing the cloud process.


And in order to see if your sensor is at all available via I2C you can use the I2C scanner code.

void setup()

  Serial.println("\nI2C Scanner");

void loop()
  byte error, address;
  int nDevices;


  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();

    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16) 
      Serial.println("  !");

    else if (error==4) 
      Serial.print("Unknow error at address 0x");
      if (address<16) 
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");

  delay(5000);           // wait 5 seconds for next scan
1 Like

thank you @ScruffR !!!
I tried unblocking the code, no success, so then tried checking my i2c with your code, and sure enough, “No I2C devices found”.

I had the LSM9DS0 connected through the breadboard, daisy-chained by jumper cables.
So I connected the LSM9DS0 directly to the photon SDA and SCL pins, and that’s when I got it to work.

Any idea what the reason is? I had it set up incorrectly or bad breadboard or wires? That’s all it could be right?

The reason could be that the jumper cables just distort the signal beyond repair and hence the library goes into a blocking state since it can’t read the data correctly.

And as I suspected, the library itself will cause the blocking in such circumstances here

byte Adafruit_LSM9DS0::readBuffer(boolean type, byte reg, byte len, uint8_t *buffer)
    // Wait around until enough data is available
    while (Wire.available() < len);

When the signal quality is too bad, Wire.available() will never reach the required count and hence the code will block indefinetly and break the cloud connection.
This line should be altered to

    while (Wire.available() < len) Particle.process();

in order to stay connected despite the bad sensor connection.


Thanks for the help @ScruffR!

1 Like