// This is an example where I try learn how to use the ESP32 on Wokwi.
// Based on the MPU6050 example
// https://wokwi.com/arduino/projects/305937248748044864
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_MPU6050 mpu;
void setup(void) {
Serial.begin(115200);
Serial.println("Hello, ESP32!"); // println() adds a newline at the end
while (!mpu.begin()) {
Serial.println("MPU6050 not connected!");
delay(1000);
}
Serial.println("MPU6050 ready!");
}
sensors_event_t event;
void loop() {
mpu.getAccelerometerSensor()->getEvent(&event);
Serial.print("["); // print() does not add a newline
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(10); // This apparently speeds up the simulation
}