To verify that I could connect my ESP32 project to the 'net and communicate with another site I thought getting the time would be a good case.
Basically I can gather the date and time but the format isn't what I expected.
The returned RTC_ESP32_NPT1::GetTimeString(1) returns 00:00:00 and repeated calls in 1 sec intervals then starts to count the seconds.
So it looks that the 1st call returns 00:00:00 and next calls return the time since the 1st call, which seems a bit weird.
The returned RTC_ESP32_NTP1::GetDateString(0) returns 01/01/226.
I could have understood 01/01/2000 or something, but really expected 13/06/2023.
What am I missing? FC attached with SSID and PW blanked out.
Jan
RTC_ESP32_NTP date/time return format
-
- Posts: 113
- http://meble-kuchenne.info.pl
- Joined: Mon Feb 13, 2023 7:56 pm
- Has thanked: 28 times
- Been thanked: 12 times
RTC_ESP32_NTP date/time return format
- Attachments
-
- ESP32 wroom wifi RTC test ili9341.fcfx
- (25.91 KiB) Downloaded 270 times
-
- Matrix Staff
- Posts: 1952
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 510 times
- Been thanked: 698 times
Re: RTC_ESP32_NTP date/time return format
Hi Jan,
Looks like you are missing a call to the QueryTimeServer macro of the RTC component. You need to do this once connected to the WIFI and then once you've done it the ESP will maintain the time on it's own. You might want to repeat the query call when possible to keep the internal timing of the ESP from drifting too far out from reality. Say once a day or once an hour should be fine.
Looks like you are missing a call to the QueryTimeServer macro of the RTC component. You need to do this once connected to the WIFI and then once you've done it the ESP will maintain the time on it's own. You might want to repeat the query call when possible to keep the internal timing of the ESP from drifting too far out from reality. Say once a day or once an hour should be fine.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: RTC_ESP32_NTP date/time return format
I changed the format specification bit to see what happens.
If I change the GetTimeString format it deletes the seconds and displays HH:MM only, which is according to spec.
Changing the Get DateString format has no effect, it still displays 01/01/226.
I do not plan to wait a year to see whether it turns over.
Edit: posted this before I saw Ben's post above. Will check that.
Edit2: I got this all wrong. I thought that GetTimeString and GetDateString would get the time/date from the 'net.
But I now understand that these are the ESP32 internal RTC, and I need to do a QueryTimeServer to get the time so the internal RTC knows the actual time. Duh.
Jan
If I change the GetTimeString format it deletes the seconds and displays HH:MM only, which is according to spec.
Changing the Get DateString format has no effect, it still displays 01/01/226.
I do not plan to wait a year to see whether it turns over.
Edit: posted this before I saw Ben's post above. Will check that.
Edit2: I got this all wrong. I thought that GetTimeString and GetDateString would get the time/date from the 'net.
But I now understand that these are the ESP32 internal RTC, and I need to do a QueryTimeServer to get the time so the internal RTC knows the actual time. Duh.
Jan