Quantcast
Channel: Sensors - Arduino Forum
Viewing all articles
Browse latest Browse all 1069

Adafruit_ICM20X library causing void setup() code to loop

$
0
0

Hi, I am using an adafruit ICM20948 and have successfully ran the example code from the github repository to receive the values. However when I copy the code from the repository into pre-existing (working code), the setup code loops all of the instructions before the:

 if (!icm.begin_I2C()) {
    Serial.println("Failed to find ICM20948 chip");
    while (1) {
      delay(10);
    }
  }

so if my code looks likes this simpler example:

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

    Serial.println("testing...");
    delay(500);

    if (!icm.begin_I2C()) {
      Serial.println("Failed to find ICM20948 chip");
      while (1) {
        delay(10);
      }
    }

    Serial.println("ICM20948 Found!");
}

my serial monitor will continuously receive testing... with 0.5 second delay, I have no idea why this is, has anyone experienced this before? to be clear I know the icm.begin_I2C() function works in isolation but it seems to be crashing when included in my code. I've considered this is due to the fact I'm using an Arduino UNO and my code uses the analogue pins 4 and 5 as outputs, which I'm aware are also capable of I2C? Since my ICM is connected with the dedicated SCL and SDA pins I assumed this wouldn't be an issue.

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1069

Trending Articles