Esp8266 randomly resets after a lot of time (9 hours)

I have esp8266, it connected to 3 temperature sensors. I put all data in list (temperature and time). After 9 hour of work esp8266 just refresh everything and all data get lost. I tried check my code, but problem still there.

I expected that it will just edit previous temperatures and it will not reset. Here is schema (without 8266):
Schema without esp8266

Here is my code:

    #include <ESP8266WiFi.h>
    #include <ESP8266WebServer.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #include <WiFiUdp.h>
    #include <EEPROM.h>
    #define SENSORS_PIN D7


    OneWire oneWire1(SENSORS_PIN);

    DallasTemperature sensors(&oneWire1);

    const int numSensors = 3;
    const int maxRecords = numSensors * 1000;
    const int INTERVAL_ADDRESS_IN_EEPROM = 0;
    float temperatures[maxRecords];
    unsigned long timestamps[maxRecords];
    int ids[maxRecords];
    int dataIndex = 0;
    unsigned long lastMillis = 0;
    int interval = 10000;


    unsigned long blink = 0;
    int blink_type = 0;

    const char* ssid = "MY-SSID";
    const char* password = "MY-PASSWORD";

    ESP8266WebServer server(80);
    WiFiUDP udp;
    const unsigned int udpPort = 4210;
    unsigned long lastUdpMillis = 0;

    int sensor_ids[numSensors] = {1,2,3};

    void writeToEEPROM(int address, int value) {
      EEPROM.put(address, value);
      EEPROM.commit();
    }

    int readFromEEPROM(int address) {
      int value;
      EEPROM.get(address, value);
      return value;
    }

    void setup() {
      pinMode(SENSORS_PIN, INPUT_PULLUP);
      pinMode(LED_BUILTIN, OUTPUT);

      sensors.begin();

      Serial.begin(9600);
      EEPROM.begin(512);

      interval = readFromEEPROM(INTERVAL_ADDRESS_IN_EEPROM);
      if (interval <= 0 || interval > 60000) {
        interval = 10000;
        writeToEEPROM(INTERVAL_ADDRESS_IN_EEPROM, interval);
        Serial.println("Interval set to default value: 10000 milliseconds");
      } else {
        Serial.printf("Current interval is %d millisecondsn", interval);
      }

      WiFi.begin(ssid, password);
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      Serial.println("nConnected to WiFi");

      Serial.print("IP Address: ");
      Serial.println(WiFi.localIP());

      udp.begin(udpPort);

      server.on("/status", []() {
        server.send(200, "text/html", "OK");
      });
      
      server.on("/setinterval", []() {
        int newInterval = server.arg("interval").toInt();
        if (newInterval > 0 && newInterval <= 60000) {
          interval = newInterval;
          writeToEEPROM(INTERVAL_ADDRESS_IN_EEPROM, interval);
          Serial.printf("Interval updated to %d millisecondsn", interval);
          server.send(200, "text/html", "<p>Interval set</p>");
        } else {
          server.send(400, "text/html", "<p>Invalid interval</p>");
        }
      });

      server.on("/exit", []() {
        Serial.println("Restarting device...");
        server.send(200, "text/html", "Exiting");
        ESP.restart();
      });

      server.on("/temp", []() {
        String sensor_id = server.arg("sensor_id");
        int limit = server.arg("limit").toInt();
        unsigned long currentMillis = millis();
        unsigned long time_frame = 0;
        bool filterByTime = server.hasArg("time");
        unsigned long requestTime = server.arg("time").toInt() * 1000;

        if (filterByTime) {
          time_frame = currentMillis - requestTime;
        } else {
          time_frame = 0;
        }

        if (limit <= 0) {
          limit = 10;
        }

        String response = "{"temperature_data":[";
        int count = 0;
        int totalMatched = 0;

        for (int i = 0; i < maxRecords; i++) {
          bool isWithinTimeFrame = !filterByTime || timestamps[i] >= time_frame;
          bool matchesSensorId = sensor_id.isEmpty() || ids[i] == sensor_id.toInt();

          if (ids[i] != 0 && isWithinTimeFrame && matchesSensorId) {
            totalMatched++;

            if (count < limit) {
              if (count > 0) {
                response += ",";
              }
              response += "{"temp":" + String(temperatures[i], 2) + ","time":" + String(currentMillis - timestamps[i]) + ","sensor_id":" + ids[i] + "}";
              count++;
            }
          }
        }

        int remainCount = totalMatched - count;
        response += "],"remain_cnt":" + String(remainCount) + "}";
        server.send(200, "application/json", response);
      });

      Serial.println("Server started");
      server.begin();
    }

    void loop() {
      server.handleClient();

      if (millis() - blink >= 100) {
        blink = millis();

        if (blink_type == 1) {
          digitalWrite(LED_BUILTIN, HIGH);
          blink_type = 0;
        }else{
          digitalWrite(LED_BUILTIN, LOW);
          blink_type = 1;
        }
      }

    if (millis() - lastMillis >= interval) {
        lastMillis = millis();

        for (int i = 0; i < numSensors; i++) {
            sensors.requestTemperatures();
            float temperature = sensors.getTempCByIndex(i);

            int lastIndex = (dataIndex - 1 + maxRecords) % maxRecords;
            int secondLastIndex = (dataIndex - 2 + maxRecords) % maxRecords;

            float lastTemperature = temperatures[lastIndex];
            float secondLastTemperature = temperatures[secondLastIndex];

            float diffLast = abs(temperature - lastTemperature);
            float diffSecondLast = abs(temperature - secondLastTemperature);

            if (diffLast <= 0.2 && diffSecondLast <= 0.2) {
                timestamps[lastIndex] = millis();
            } else {
                temperatures[dataIndex] = temperature;
                timestamps[dataIndex] = millis();
                ids[dataIndex] = sensor_ids[i];
                dataIndex = (dataIndex + 1) % maxRecords;
            }
        }
    }


      if (millis() - lastUdpMillis > 1000) {
        int packetSize = udp.parsePacket();
        if (packetSize) {
          char packetBuffer[255];
          int len = udp.read(packetBuffer, sizeof(packetBuffer) - 1);
          packetBuffer[len] = '';
          if (len > 0) {
            String packetString = String(packetBuffer);

            if (packetString.indexOf("DISCOVER") >= 0) {
              if (packetString.indexOf(WiFi.localIP().toString()) < 0) { 
                IPAddress remoteIp = udp.remoteIP();
                Serial.print("Device with IP: ");
                Serial.print(remoteIp);
                Serial.print(" is attempting to connect...");

                udp.beginPacket(remoteIp, udpPort);
                String message = "'DEVICE' ," + String(numSensors) + ", [";
                for (int i = 0; i < numSensors; i++) {
                  message += sensor_ids[i];
                  if (i < numSensors - 1)  message += ", ";
                }
                message += "]";
                udp.print(message);
                udp.endPacket();
                Serial.println("Response packet sent");
              }
            }
          } else {
            Serial.println("Error reading UDP packet");
          }
        }
        lastUdpMillis = millis();
      }
    }
```

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật