Page 1 of 1

get current time in millis()

Posted: Fri Jul 21, 2017 9:58 am
by Saskia
I try to get the time which the esp32 has power in millis. In the Arduino IDE, the function millis() gives that millis. How can i realize that in the esp idf?
error: implicit declaration of function 'millis' [-Werror=implicit-function-declaration]
unsigned long currentMillis = millis();
FreeRTOS also have a similar function calles getTimeSinceStart(). But how can i use this in my project?


Edit: Well, unsigned long currentMillis = xTaskGetTickCount();
is working, why not unsigned long currentMillis = getTimeSinceStart()?

Re: get current time in millis()

Posted: Fri Jul 21, 2017 10:10 am
by f.h-f.s.
This is how arduino gets millis https://github.com/espressif/arduino-es ... misc.c#L50

You can also call esp_log_timestamp() from esp_log.h which is the same timestamp used in the ESP_LOGx() functions.

You can also use arduino in esp-idf https://github.com/espressif/arduino-es ... -component

Re: get current time in millis()

Posted: Fri Jul 21, 2017 3:05 pm
by kolban
This might be a useful previous post:

https://esp32.com/viewtopic.php?t=1468

If it were me, I'd probably use "gettimeofday".

Re: get current time in millis()

Posted: Tue Jul 10, 2018 1:15 pm
by senthil313
i have to read current UNIX time ...but it is more than long int ...
i want to print this value using client.println() for web page communication...
but it not allows..

please,give any solution for read current UNIX time and send it to web page...