Adafruit 9DOF inconsistent behavior

Hey all

I am experiencing a rather strange problem with both the Adafruit 9-DoF and the Adafruit 10-DoF accelerometer on a particle photon.

My setup is like this:

Except instead of using port A4 and A5, i’m using D0 as SDA and D1 as SCL, and naturally the Photon only supplies 3.3V.

Using the library https://github.com/pkourany/Adafruit_9DOF_Library/blob/master/examples/tester/tester.ino and example code from there, i got my code to work, but after a while it started behaving strangely, and finally stopped working all together.

Basically i follow this example:

#include "Adafruit_Sensor.h"
#include "Adafruit_LSM303_U.h"
#include "Adafruit_9DOF.h"

/* Assign a unique ID to the sensors */
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);

void setup(void)
{
  Serial.begin(115200);

  /* Initialise the sensors */
  if(!accel.begin())
  {
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
    while(1);
  }
}

void loop(void)
{
  /* Get a new sensor event */
  sensors_event_t event;

  /* Display the results (acceleration is measured in m/s^2) */
  accel.getEvent(&event);
  Serial.print("ACCEL ");
  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 ");

  Serial.println("");
  delay(1000);
}

But after a while, the loop simply stops when running the line:

accel.getEvent(&event);

This has happened three times now with two different 10-DoF and a 9-DoF.

Frankly i’m stumped.

Do any of you have an idea about what could be happening?

@simonhmadsen, which version of system firmware are you using on the Photon. I suggest you add SYSTEM_THREAD(ENABLED); just before setup. This library is an older one and looking at Adafruit’s site I can see they have a newer all-in-one library. It should still work however. Have you tested it on an UNO?

I recently ported the unified sensor library for the Adafruit 10DOF and I haven’t seen a problem on the Photon, though I didn’t run it for that long.

My port of the library is in the community libraries as Adafruit_10DOF_IMU and here on Github: https://github.com/rickkas7/Adafruit_10DOF_IMU

3 Likes

I let it run for an hour at 25 samples/sec. At some point, it stopped responding for me as well. I’m pretty sure the accelerometer gets into a bad state. Resetting just the Photon didn’t cause it to resume, as you would expect if it was a bug in the software. I unplugged the USB power, which would have reset the sensor board, and then it resumed working properly. I’ll have to do some proper tests with debugging code in place later when I get a chance.

1 Like