Hi there. Relatively new to Arduino and all this, and I have a question that I can't seem to find a clear answer for. Hopefully this is a good place to ask.
I got the IMU working fine, and am able to read 3 axes of Acc and Gyro, so that's all good.
But it seems to me that there is no way to know whether the board is lying right way up, or upside-down. Is it correct that according to the IMU those 2 states are the same? Or am I using the wrong measurements? I've included my code below, but there doesn't seem to be a problem with the code.
// Include onboard Nano 33 IOT IMU
#include <Arduino_LSM6DS3.h>
void setup() {
Serial.begin(9600);
// start the IMU:
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU");
// stop here if you can't access the IMU:
while (true);
}
}
void loop() {
// values for acceleration & rotation:
float xAcc, yAcc, zAcc;
float xGyro, yGyro, zGyro;
// if both accelerometer and gyrometer are ready to be read:
if (IMU.accelerationAvailable() &&
IMU.gyroscopeAvailable()) {
// read accelerometer and gyrometer:
IMU.readAcceleration(xAcc, yAcc, zAcc);
// print the results:
IMU.readGyroscope(xGyro, yGyro, zGyro);
Serial.print(xGyro);
Serial.print(",");
Serial.print(yGyro);
Serial.print(",");
Serial.print(zGyro);
Serial.print(",");
Serial.print(xAcc);
Serial.print(",");
Serial.print(yAcc);
Serial.print(",");
Serial.print(zAcc);
Serial.print(",");
}
}