ESP-IDF equivalent of Arduino millis()
In Arduino, the millis()
function returns the number of milliseconds since the program started. In ESP-IDF, you can achieve the same functionality using the esp_timer_get_time()
function, which returns the time in microseconds. To convert it to milliseconds, you need to divide by 1000.
#include <esp_timer.h>
uint32_t millis() {
return esp_timer_get_time() / 1000;
}
// Usage example
void myFunc() {
uint32_t currentMillis = millis();
// Use currentMillis as needed
}
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow