#include #include #include #include // Wi-Fi credentials const char* ssid = "YOUR_WIFI_NAME"; const char* password = "YOUR_WIFI_PASSWORD"; // Web server on port 80 WebServer server(80); // MPU6050 object MPU6050 mpu; int16_t ax, ay, az, gx, gy, gz; void setup() { Serial.begin(115200); Wire.begin(5, 4); // SDA = GPIO5, SCL = GPIO4 // Connect to Wi-Fi WiFi.begin(ssid, password); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWiFi connected. IP address: "); Serial.println(WiFi.localIP()); // Start MPU6050 mpu.initialize(); if (!mpu.testConnection()) { Serial.println("MPU6050 connection failed!"); while (1); } // Define web route server.on("/", handleRoot); server.begin(); Serial.println("Web server started"); } void loop() { // Get MPU6050 data mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // Handle incoming web clients server.handleClient(); } void handleRoot() { String html = "" "" "

MPU6050 Sensor Data

" "

Accelerometer:
" "X = " + String(ax) + "
" + "Y = " + String(ay) + "
" + "Z = " + String(az) + "

" + "

Gyroscope:
" "X = " + String(gx) + "
" + "Y = " + String(gy) + "
" + "Z = " + String(gz) + "

" + ""; server.send(200, "text/html", html); }