Hello,
I'm trying to get the IMU data with example code for the LSM6DS3
But when I analyse the data, I found some strange data as shown in image below.
/*
Arduino LSM6DS3 - Simple Accelerometer
This example reads the acceleration values from the LSM6DS3
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.
The circuit:
- Arduino Uno WiFi Rev 2 or Arduino Nano 33 IoT
created 10 Jul 2019
by Riccardo Rizzo
This example code is in the public domain.
*/
#include <Arduino_LSM6DS3.h>
long count = 0;
long start_time = 0;
long end_time = 0;
long hz = 0;
void setup() {
Serial.begin(115200);
while (!Serial);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("start");
}
void loop() {
float x, y, z;
float gx, gy, gz;
if (IMU.accelerationAvailable()&&IMU.gyroscopeAvailable()) {
IMU.readAcceleration(x, y, z);
IMU.readGyroscope(gx, gy, gz);
Serial.print(count);
Serial.print(", acc, ");
Serial.print(x * 9.80665, 4);
Serial.print(", ");
Serial.print(y * 9.80665, 4);
Serial.print(", ");
Serial.print(z * 9.80665, 4);
Serial.print(", gyro, ");
Serial.print(gx * 0.01745329, 4);
Serial.print(", ");
Serial.print(gy * 0.01745329, 4);
Serial.print(", ");
Serial.println(gz * 0.01745329, 4);
}
count++;
delay(3);
}
Is there anyone can explain what happened? Thank you so much.
