Hello! I've been working on a project to measure the vibration (Hz) using a BNO055 accelerometer. So far, I was able to measure the acceleration in x, y, and z. I'm also able to plot the vibration in the "Serial Plotter". The last step is to find the frequency of vibration. I've been trying at it for two days now, but I'm still not able to find the right set of codes to obtain it. I've come to the conclusion that there are three possible ways to find it. However, I didn't know how to implement any of them. The three methods are:
Using Fast Fourier Transformation (FFT).
Finding all the local maximum then finding the average period between two peaks. (doesn't seem
practical)
Finally, using some of the Frequency libraries Arduino offers such as FreqCount... etc.
I would truly appreciate the help.
Please find code below.
Thank you!
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055();
void setup(void)
{
Serial.begin(115200);
Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");
/* Initialise the sensor /
if (!bno.begin())
{
/ There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while (1);
}
delay(1000);
Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated");
}
void loop(void)
{
/* Display calibration status for each sensor. */
uint8_t system, gyro, accel, mag = 0;
bno.getCalibration(&system, &gyro, &accel, &mag);
Serial.print("CALIBRATION: Sys=");
Serial.print(system, DEC);
Serial.print(" Gyro=");
Serial.print(gyro, DEC);
Serial.print(" Accel=");
Serial.print(accel, DEC);
Serial.print(" Mag=");
Serial.println(mag, DEC);
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);
/* Display the floating point data */
Serial.print("X: ");
Serial.print(euler.x());
Serial.print(" Y: ");
Serial.print(euler.y());
Serial.print(" Z: ");
Serial.print(euler.z());
Serial.print("\t\t");
}