The code below compiled and run successfully but I can see the data on the serial monitor but nothing shows when I open the IP address. The task is to visualize the data on the IP not the serial monitor. Please what am I doing wrong?
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_MPU6050 mpu;
#ifndef STASSID
#define STASSID "kicky"
#define STAPSK "12341234"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
void setup() {
Serial.begin(2000000);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// Hostname defaults to esp8266-[ChipID]
// ArduinoOTA.setHostname("myesp8266");
// No authentication by default
//ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA.onStart([]() {
Serial.println("Start");
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_FS
type = "filesystem";
}
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) {
Serial.println("Auth Failed");
} else if (error == OTA_BEGIN_ERROR) {
Serial.println("Begin Failed");
} else if (error == OTA_CONNECT_ERROR) {
Serial.println("Connect Failed");
} else if (error == OTA_RECEIVE_ERROR) {
Serial.println("Receive Failed");
} else if (error == OTA_END_ERROR) {
Serial.println("End Failed");
}
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
//pinMode(2, OUTPUT);
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(1);
}
}
}
bool ota_flag = true;
uint16_t time_elasped = 0;
void loop() {
if(ota_flag)
{
while(time_elasped < 1000)
{
ArduinoOTA.handle();
time_elasped = millis();
delay(10);
}
ota_flag = false;
}
//digitalWrite(2,!digitalRead(2));
delay(100);
sensors_event_t a, g, temp;
mpu.getEvent(&a,&g, &temp);
/* Print out the values */
//Serial.print("Acceleration X: ");
Serial.print(a.acceleration.x);
Serial.print(",");
Serial.print(a.acceleration.y);
Serial.print(",");
Serial.println(a.acceleration.z);
delay(100);
}
This is the serial monitor
IP address: 192.168.157.180
-1.39,0.79,8.16
-1.18,0.96,8.01
-1.01,1.00,7.72
-1.12,1.03,7.82
-1.18,0.89,7.92
-1.04,0.91,7.88
-1.07,0.98,7.91
-1.06,0.98,7.77
-1.04,0.96,7.93
-1.08,0.98,7.88