Hi everyone,
I’m using an Arduino Mega and the LSM6DS3 sensor to measure acceleration and angular velocity on a formula-style car. The code I am using is as follows:
#include <Wire.h>
#include "SparkFunLSM6DS3.h"
#define ENABLE_ACCEL
#define ENABLE_GYRO
LSM6DS3 myIMU(I2C_MODE, 0x6B);
void setup() {
Serial.begin(115200);
Wire.begin();
delay(50);
if (myIMU.begin() != 0) {
Serial.println("LSM6DS3 initialization failed");
while (1);
}
Serial.println("LSM6DS3 initialization succeeded");
}
void loop() {
// Acceleration
float ax = myIMU.readFloatAccelX();
float ay = myIMU.readFloatAccelY();
float az = myIMU.readFloatAccelZ();
// Angular velocity
float gx = myIMU.readFloatGyroX();
float gy = myIMU.readFloatGyroY();
float gz = myIMU.readFloatGyroZ();
// Print
Serial.print("Accel: ");
Serial.print(ax); Serial.print(", ");
Serial.print(ay); Serial.print(", ");
Serial.println(az);
Serial.print("Gyro: ");
Serial.print(gx); Serial.print(", ");
Serial.print(gy); Serial.print(", ");
Serial.println(gz);
delay(10); // 10ms cycle
}
However, I often get readings of around 4 G that shouldn’t appear. Since the car uses a single-cylinder engine, the vibrations are very high and noisy, which makes it difficult to get accurate data.
I would like to ask if there are any hardware or software solutions to improve the measurement accuracy in such a high-vibration environment. For example, filtering, mounting techniques, or changes in sampling and communication.
Any advice would be greatly appreciated.
Thank you!
