cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards
https://cyberman54.github.io/ESP32-Paxcounter/
Other
1.7k stars 399 forks source link

What happenes when millis() rolls over after ~49 days? #685

Closed cyberman54 closed 3 years ago

cyberman54 commented 3 years ago

Check what's happening, and how to solve concerning issues.

cyberman54 commented 3 years ago

millis() in arduino esp32 is based on esp_timer_get_time(void) which will roll over in 100+ years. But it's defined as unsigned long, so will roll over after ~49 days!?

unsigned long IRAM_ATTR millis()
{
    return (unsigned long) (esp_timer_get_time() / 1000ULL);
}
cyberman54 commented 3 years ago

Tests showed, that devices do live more than 49 days. I don't yet understand why, but it seems this is not an issue, so i am closing this.