#define BLYNK_TEMPLATE_ID "TMPL3368uYvYY"
#define BLYNK_TEMPLATE_NAME "MPU6050"
#define BLYNK_AUTH_TOKEN "eK_mbPxu9W1uSpRf86Y-e6HjlNT79sqN"
#include <Wire.h>
#include <MPU6050.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "eK_mbPxu9W1uSpRf86Y-e6HjlNT79sqN";
MPU6050 mpu;
void setup() {
Wire.begin();
Serial.begin(115200);
mpu.initialize();
// Calibrate the sensor
mpu.CalibrateGyro();
mpu.CalibrateAccel();
mpu.setDMPEnabled(true); // Enables the Digital Motion Processor (DMP)
Blynk.begin(auth, " JJ", "pavan1107"); // Connect to Wi-Fi
while (!Blynk.connected()) {
Serial.print("configuration issue");
}
}
void loop() {
// Read accelerometer values
int16_t ax, ay, az;
mpu.getAcceleration(&ax, &ay, &az);
Serial.print("X scale:");
Serial.println(ax);
Serial.print("Yscale:");
Serial.println(ay);
Serial.print("Zscale:");
Serial.println(az);
float magnitude = sqrt(ax * ax + ay * ay + az * az);
Serial.print("magnitude:");
Serial.println(magnitude);
float vibrationThreshold = 30000.0; // Adjust this threshold as needed
if (magnitude > vibrationThreshold) {
Serial.println("Vibration detected!");
}
delay(1000); // Adjust the delay based on your requirements
}