Sparkfun nRF52840 mini

Hello,

Recently i bought some SparkFun nrf52840 mini and SparkFun LSM9DS1.

The problem is that, sometimes, the board nrf52840 seems to get stuck and don’t even do the setup function. The conditions are a bit random, somethimes i upload code and works fine, but when i upload it again, doesn’t work.

This scenario occour in the following code:

#include <Wire.h>
#include <SparkFunLSM9DS1.h>

LSM9DS1 imu;


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

#define DECLINATION -8.58

int i = 0;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  Serial.begin(115200);

  while(!Serial) delay(10);
  
  pinMode(LED_BLUE, OUTPUT);

  digitalToggle(LED_BLUE);
  delay(200);
  Serial.println("Ok");
  digitalToggle(LED_BLUE);
  delay(200);
  Serial.println("That works");

  imu.settings.device.commInterface = IMU_MODE_I2C;
  
  imu.settings.device.mAddress = LSM9DS1_M;
  imu.settings.device.agAddress = LSM9DS1_AG;
}
     
// the loop function runs over and over again forever
void loop() {
  i++;

  Serial.print(i);
  Serial.print(" -  ");
  
  if(imu.accelAvailable()){
    imu.readAccel();
    Serial.println(imu.ax);
  }
  
  Serial.println();
  digitalToggle(LED_BLUE);   // turn the LED on (HIGH is the voltage level)
  delay(200);              // wait for a second
}

When it doesn’t work, i have cases tha only the “Ok” is displayed in the serial monitor or even cases that i don’t get nothing.

Maybe is a problem with the serial communication.

If someone have a glimpse in how to fiz that or why this is occouring, i whould like to hear.

Thanks.

Hi xandeulson,

Correct me if I am wrong but it does not look like you are calling begin() in your setup for the IMU. Can you try running the [Basic I2C Example from the library and let me know if that works more reliably?](SparkFun_LSM9DS1_Arduino_Library/examples/LSM9DS1_Basic_I2C/LSM9DS1_Basic_I2C.ino at master · sparkfun/SparkFun_LSM9DS1_Arduino_Library · GitHub)