Odd problem with Nano 33 IOT IMU

using Nano 33 IOT, uploading to arduino cloud

Hi there, does anyone know why I am getting these two errors?

One problem with line 'if(!IMU.begin())' , it's written the same as the simple gyroscope example sketch.

Also, why am I getting errors on 'multiple libraries found'

Thanks

// Arduino_LSM6DS3 - Version: 1.0.2

#include <Arduino_LSM6DS3.h>
#include "thingProperties.h"

#define CellVoltage1 A0
#define CellVoltage2 A6
#define CellVoltage3 A7

float Measured_VoltageCell1 = 0.0;
//float Actual_VoltageCell1 = 0.0; Declared in Cloud

float Measured_VoltageCell2 = 0.0;
//float Actual_VoltageCell2 = 0.0;

float Measured_VoltageCell3 = 0.0;
//float Actual_VoltageCell3 = 0.0; Declared in Cloud

//float Total_VoltageCell = 0.0;
//float Lipo_Capacity = 0.0; Declared in Cloud
//bool LipoVoltageTooHigh = false;
//bool LipoVoltageTooLow = false;
//bool LipoVoltageWarningLow = false;

float R1 = 30000.0;
float R2 = 7500.0;

int greenPin = A2;
int redPin = A1;
int bluePin = A3;

int adc_value1 = 0;
int adc_value2 = 0;
int adc_value3 = 0;

#define ON 255
#define OFF 0

void setup() {
analogReference(AR_INTERNAL1V0); //Uses 1V Internal Reference
Serial.begin(9600);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo(

if(!IMU.begin()) {
Serial.println("Failed to initialize the LSM6DS3 sensor!");
while (1);
}

pinMode(redPin, OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);

initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();

}

void loop() {

ArduinoCloud.update();

Measured_VoltageCell1 = analogRead(CellVoltage1);
Measured_VoltageCell1 = (adc_value1 * AR_INTERNAL1V0) / 1024.0;
Actual_VoltageCell1 = Measured_VoltageCell1 / (R2/(R1+R2));

Measured_VoltageCell2 = analogRead(CellVoltage3);
Measured_VoltageCell2 = (adc_value2 * AR_INTERNAL1V0) / 1024.0;
Actual_VoltageCell2 = Measured_VoltageCell2 / (R2/(R1+R2));

Measured_VoltageCell3 = analogRead(CellVoltage3);
Measured_VoltageCell3 = (adc_value3 * AR_INTERNAL1V0) / 1024.0;
Actual_VoltageCell3 = Measured_VoltageCell3 / (R2/(R1+R2));

Total_VoltageCell = Actual_VoltageCell1 + Actual_VoltageCell2 + Actual_VoltageCell3;
//Lipo_Capacity = (-40.734(pow(Total_VoltageCell,6)) + (2816pow(Total_VoltageCell,5)) + (-80993pow(Total_VoltageCell,4)) + (2816*pow(Total_VoltageCell,5));
if(Total_VoltageCell >12.45){
Lipo_Capacity = 100;
LipoVoltageTooHigh = true;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >12.33 && Total_VoltageCell <= 12.45){
Lipo_Capacity = 95;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >12.25 && Total_VoltageCell <= 12.33){
Lipo_Capacity = 90;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >12.07 && Total_VoltageCell <= 12.25){
Lipo_Capacity = 85;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.95 && Total_VoltageCell <= 12.07){
Lipo_Capacity = 80;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >11.86 && Total_VoltageCell <= 11.95){
Lipo_Capacity = 75;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >11.74 && Total_VoltageCell <= 11.86){
Lipo_Capacity = 70;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >11.62 && Total_VoltageCell <= 11.74){
Lipo_Capacity = 65;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.56 && Total_VoltageCell <= 11.62){
Lipo_Capacity = 60;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >11.51 && Total_VoltageCell <= 11.56){
Lipo_Capacity = 55;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.45 && Total_VoltageCell <= 11.51){
Lipo_Capacity = 50;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}
if(Total_VoltageCell >11.39 && Total_VoltageCell <= 11.45){
Lipo_Capacity = 45;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.36 && Total_VoltageCell <= 11.39){
Lipo_Capacity = 40;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.30 && Total_VoltageCell <= 11.36){
Lipo_Capacity = 35;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.24 && Total_VoltageCell <= 11.30){
Lipo_Capacity = 30;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = false;
}

if(Total_VoltageCell >11.18 && Total_VoltageCell <= 11.24){
Lipo_Capacity = 25;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = false;
LipoVoltageWarningLow = true;

}

if(Total_VoltageCell <= 11.12){
Lipo_Capacity = 0;
LipoVoltageTooHigh = false;
LipoVoltageTooLow = true;
LipoVoltageWarningLow = false;
}

// Read gyroscope data
if(WheelOn == true && LipoVoltageTooLow == false ){ // If user turns on wheel from phone and the lipo battery is not depleted
float x,y,z;
IMU.readGyroscope(x,y,z);

static float prevAngularVelocityZ = 0.0;

float deltaAngularVelocityZ = z - prevAngularVelocityZ;

// Update previous angular velocity values for the next iteration

prevAngularVelocityZ = z;

// Output angular acceleration values

float angularAccelerationZ = deltaAngularVelocityZ / IMU.gyroscopeSampleRate();

Serial.print("Angular Acceleration Z: ");
Serial.print(angularAccelerationZ);
Serial.println(" deg/s^2");

delay(10); // Adjust the delay based on your required sampling rate

if(angularAccelerationZ >= Acc_Sense){
analogWrite(redPin,OFF);
analogWrite(greenPin,ON );
analogWrite(bluePin,OFF);

}

else if(angularAccelerationZ < Brake_Sense){
analogWrite(redPin,ON);
analogWrite(greenPin,OFF);
analogWrite(bluePin,OFF);

}
else if(angularAccelerationZ == No_Sense){
analogWrite(redPin,OFF);
analogWrite(greenPin,OFF );
analogWrite(bluePin,ON);

}

}

else if(WheelOn== false){ // If user turns off wheel from phone
analogWrite(redPin,OFF);
analogWrite(greenPin,OFF );
analogWrite(bluePin,OFF);

}

}
/*
Since AccSense is READ_WRITE variable, onAccSenseChange() is
executed every time a new value is received from IoT Cloud.
/
void onAccSenseChange() {
// Add your code here to act upon AccSense change
}
/

Since BrakeSense is READ_WRITE variable, onBrakeSenseChange() is
executed every time a new value is received from IoT Cloud.
/
void onBrakeSenseChange() {
// Add your code here to act upon BrakeSense change
}
/

Since NoSense is READ_WRITE variable, onNoSenseChange() is
executed every time a new value is received from IoT Cloud.
/
void onNoSenseChange() {
// Add your code here to act upon NoSense change
}
/

Since WheelOn is READ_WRITE variable, onWheelOnChange() is
executed every time a new value is received from IoT Cloud.
/
void onWheelOnChange() {
// Add your code here to act upon WheelOn change
}
/

Since ActualVoltageCell1 is READ_WRITE variable, onActualVoltageCell1Change() is
executed every time a new value is received from IoT Cloud.
/
void onActualVoltageCell1Change() {
// Add your code here to act upon ActualVoltageCell1 change
}
/

Since ActualVoltageCell2 is READ_WRITE variable, onActualVoltageCell2Change() is
executed every time a new value is received from IoT Cloud.
/
void onActualVoltageCell2Change() {
// Add your code here to act upon ActualVoltageCell2 change
}
/

Since ActualVoltageCell3 is READ_WRITE variable, onActualVoltageCell3Change() is
executed every time a new value is received from IoT Cloud.
/
void onActualVoltageCell3Change() {
// Add your code here to act upon ActualVoltageCell3 change
}
/

Since LipoCapacity is READ_WRITE variable, onLipoCapacityChange() is
executed every time a new value is received from IoT Cloud.
/
void onLipoCapacityChange() {
// Add your code here to act upon LipoCapacity change
}
/

Since TotalVoltageCell is READ_WRITE variable, onTotalVoltageCellChange() is
executed every time a new value is received from IoT Cloud.
/
void onTotalVoltageCellChange() {
// Add your code here to act upon TotalVoltageCell change
}
/

Since LipoVoltageTooHigh is READ_WRITE variable, onLipoVoltageTooHighChange() is
executed every time a new value is received from IoT Cloud.
/
void onLipoVoltageTooHighChange() {
// Add your code here to act upon LipoVoltageTooHigh change
}
/

Since LipoVoltageTooLow is READ_WRITE variable, onLipoVoltageTooLowChange() is
executed every time a new value is received from IoT Cloud.
/
void onLipoVoltageTooLowChange() {
// Add your code here to act upon LipoVoltageTooLow change
}
/

Since LipoVoltageWarningLow is READ_WRITE variable, onLipoVoltageWarningLowChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLipoVoltageWarningLowChange() {
// Add your code here to act upon LipoVoltageWarningLow change
}

Start verifying
/tmp/634282900/CarWheels_jan07a/CarWheels_jan07a.ino: In function 'void setup()':
/tmp/634282900/CarWheels_jan07a/CarWheels_jan07a.ino:58:3: error: expected primary-expression before 'if'
if(!IMU.begin()) {
^~
Multiple libraries were found for "WiFiNINA.h"
Used: /home/builder/opt/libraries/wifinina_1_8_14
Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1
Multiple libraries were found for "ArduinoECCX08.h"
Used: /home/builder/opt/libraries/arduinoeccx08_1_3_7
Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0
Multiple libraries were found for "Arduino_LSM6DS3.h"
Used: /home/builder/opt/libraries/arduino_lsm6ds3_1_0_2
Not used: /home/builder/opt/libraries/arduino_lsm6ds3_1_0_2
Multiple libraries were found for "Wire.h"
Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/Wire
Not used: /home/builder/opt/libraries/flexwire_1_1_2
Multiple libraries were found for "SPI.h"
Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/SPI
Not used: /home/builder/opt/libraries/eventethernet_1_0_0
Error during build: exit status 1

/tmp/634282900/CarWheels_jan07a/CarWheels_jan07a.ino: In function 'void setup()':
/tmp/634282900/CarWheels_jan07a/CarWheels_jan07a.ino:58:3: error: expected primary-expression before 'if'
if(!IMU.begin()) {
^~
Multiple libraries were found for "WiFiNINA.h"
Used: /home/builder/opt/libraries/wifinina_1_8_14
Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1
Multiple libraries were found for "ArduinoECCX08.h"
Used: /home/builder/opt/libraries/arduinoeccx08_1_3_7
Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0
Multiple libraries were found for "Arduino_LSM6DS3.h"
Used: /home/builder/opt/libraries/arduino_lsm6ds3_1_0_2
Not used: /home/builder/opt/libraries/arduino_lsm6ds3_1_0_2
Multiple libraries were found for "Wire.h"
Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/Wire
Not used: /home/builder/opt/libraries/flexwire_1_1_2
Multiple libraries were found for "SPI.h"
Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/SPI
Not used: /home/builder/opt/libraries/eventethernet_1_0_0
Error during build: exit status 1

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

As your problem does not relate to Avrdude it has been moved to the Nano IOT 33 category of the forum

Ok, thanks

Your real error is in this area of code

setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo(

if(!IMU.begin()) {
Serial.println("Failed to initialize the LSM6DS3 sensor!");
while (1);
}

There is no closing bracket or semicolon on the call to ArduinoCloud.printDebugInfo

There may be other problems but this needs fixing

Thanks, it all works now

The clue was in the error message

 error: expected primary-expression before 'if'
if(!IMU.begin()) {
^~

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.