Flora and LSM9DS0

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
SeaSparks
 
Posts: 1
Joined: Wed Dec 18, 2013 12:46 pm

Flora and LSM9DS0

Post by SeaSparks »

I am working on this little Halloween project with my son, however we can not get it get through setup() when on battery power. Works great when I am debugging via serial and plugged in via usb. Interestingly the code will not run when the board is first plugged in, and only starts when I open the serial debugger window. This is the clue that has me thinking I did something wrong in setup! HELP!

I did try adding the code to light up the on-board red led here and there, I know for sure I am getting to setup, and then not making it past while (!Serial); // wait for flora/leonardo which I copied from the test example in the library.

Code: Select all

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM9DS0.h>

#define PIN 12
#define NUMPIXELS      1
#define MOVE_THRESHOLD 4000    
#define BIG_MOVE_THRESHOLD 9000

/* Assign a unique base ID for this sensor */
Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(1000);  // Use I2C, ID #1000

#define LSM9DS0_XM_CS 10
#define LSM9DS0_GYRO_CS 9
//Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(LSM9DS0_XM_CS, LSM9DS0_GYRO_CS, 1000);

#define LSM9DS0_SCLK 13
#define LSM9DS0_MISO 12
#define LSM9DS0_MOSI 11

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  while (!Serial);  // wait for flora/leonardo
  
  Serial.begin(9600);
  Serial.println(F("LSM9DS0 9DOF Sensor Test")); 
  
  if(!lsm.begin())
  {
    /* There was a problem detecting the LSM9DS0 ... check your connections */
    Serial.print(F("Ooops, no LSM9DS0 detected ... Check your wiring or I2C ADDR!"));
    
    while(1);
  }
  
  Serial.println(F("Found LSM9DS0 9DOF"));
  /* Setup the sensor gain and integration time */
  configureSensor();
  
    /* We're ready to go! */
  Serial.println("");
  
  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'
  }

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Flora and LSM9DS0

Post by adafruit_support_bill »

...only starts when I open the serial debugger window. This is the clue that has me thinking I did something wrong in setup!
Good analysis! That takes us right to the problem. Your code is waiting for the serial monitor to connect in this line right here:

Code: Select all

 while (!Serial);  // wait for flora/leonardo
Have fun with your project and have a happy Halloween!

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”