get current time in millis()

Saskia
Posts: 40
Joined: Mon Jun 26, 2017 11:45 am

get current time in millis()

Postby Saskia » Fri Jul 21, 2017 9:58 am

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()?
Last edited by Saskia on Fri Jul 21, 2017 10:13 am, edited 1 time in total.

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: get current time in millis()

Postby f.h-f.s. » Fri Jul 21, 2017 10:10 am

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: get current time in millis()

Postby kolban » Fri Jul 21, 2017 3:05 pm

This might be a useful previous post:

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

If it were me, I'd probably use "gettimeofday".
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

senthil313
Posts: 8
Joined: Fri May 11, 2018 5:44 am

Re: get current time in millis()

Postby senthil313 » Tue Jul 10, 2018 1:15 pm

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...

Who is online

Users browsing this forum: liamm36 and 127 guests