How can I set the date / time?

pete_l
Posts: 2
Joined: Fri Mar 16, 2018 11:18 am

How can I set the date / time?

Postby pete_l » Sun Jun 10, 2018 5:42 pm

I an moving some code from an ESP8266 to an ESP32.
I am using the Arduino IDE
I wish to set an arbitrary date and time

In the ESP8266 code I can use a library function called setTime(). However this doesn't exist in the ESP32 version of the libraries.
There is an example in the Expressif code that uses the Unix-y settimeofday(&tv, &tz) function. However this example requires a header file called coredecls.h that does not appear on the code base I installed with the ESP32 Arduino environment.

What do you do to set the time without using NTP?

with thanks!

avdalimov14
Posts: 7
Joined: Tue Apr 17, 2018 2:24 pm

Re: How can I set the date / time?

Postby avdalimov14 » Sun Jun 17, 2018 2:13 pm

What do you do to set the time without using NTP?


I would like to join this question.

WiFive
Posts: 1817
Joined: Tue Dec 01, 2015 7:35 am

Re: How can I set the date / time?

Postby WiFive » Sun Jun 17, 2018 5:38 pm

Did you try

Code: Select all

#include <time.h>
#include <sys/time.h>

avdalimov14
Posts: 7
Joined: Tue Apr 17, 2018 2:24 pm

Re: How can I set the date / time?

Postby avdalimov14 » Mon Jun 18, 2018 1:35 pm

Yes, but I couldn't figure out what the time val that I should put in settimeofday?

Let's assume I want to update it to 18 June 2018 (now it is on his release data - default), How should I make it?

WiFive
Posts: 1817
Joined: Tue Dec 01, 2015 7:35 am

Re: How can I set the date / time?

Postby WiFive » Mon Jun 18, 2018 2:48 pm


Who is online

Users browsing this forum: No registered users and 1 guest