#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_MPU6050 mpu;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
while(!mpu.begin()){
Serial.println("MPU6050 not connected!");
delay(1000);
}
Serial.println("MPU6050 ready!");
}
sensors_event_t event;
void loop() {
// put your main code here, to run repeatedly:
mpu.getAccelerometerSensor()->getEvent(&event);
Serial.print("[");
Serial.print(millis());
Serial.print("] x: ");
Serial.print(event.acceleration.x);
Serial.print(", Y: ");
Serial.print(event.acceleration.y);
Serial.print(", Z: ");
Serial.print(event.acceleration.z);
Serial.println(" m/s^2");
delay(2000); // this speeds up the simulation
}