ESP-IDF documentation says use settimeofday() to set the RTC.
"To stop smooth time adjustment and update the current time immediately, use the POSIX function settimeofday()."
When I compile IDE (VSC) says settimeofday() not declared. Is there a library I need?
settimeofday() not working
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: settimeofday() not working
Did you
?
Code: Select all
#include <sys/time.h>
-
- Posts: 5
- Joined: Sat Aug 26, 2023 9:34 pm
Re: settimeofday() not working
Thank you. #include <sys/time.h> worked.
I have found no mention of sys/time.h anywhere in ESP-IDF documentation or examples. Where should I have found this information?
I have found no mention of sys/time.h anywhere in ESP-IDF documentation or examples. Where should I have found this information?
-
- Posts: 1702
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: settimeofday() not working
https://docs.espressif.com/projects/esp ... rrent-time:
i.e. it's not an IDF function; that's why it's not specifically documented with the IDF.use the POSIX function settimeofday().
(https://linuxhint.com/gettimeofday-settimeofday-c/)The settimeofday () function is a standard function whose definition is mentioned in a header file in the C library named sys/time.h
Who is online
Users browsing this forum: Baidu [Spider], Groot_05 and 97 guests