I'm using the library : #include <MKRGSM.h>
I have a problem when I try to get the time with the command:
MODEM.send("AT+CCLK?");
if (MODEM. waitForResponse(100, &response) != 1)
{
Serial. println("Issue while acquiring AT+CCLK?, reset after wacthdog's timer");
while(1) {}
}
Serial.println(response);
Answer--> +CCLK: "04/01/01,00:00:38+04" which corresponds to the factory-programmed value. Instead of this, I should have something like +CCLK: "22/12/28,16:11:38+04" corresponding to the actual date.
I did some other tests. Finally I manage to recover the date, then I lose it again. I feel like it's network dependent, even though my arduino hasn't moved. It's a shame, but this thing does not suit me, I will have to go on an external RTC module I think, unless someone has an explanation?
I adapted it for my time zone and it works well, thank you!
Do you know what the data consumption is for sending a request? I only have 50MB of data per month. I think updating the time once every hour is enough? Or even a day would be ok.
NTP is a UDP-based protocol and NTP packets are relatively small, and without any optional extensions the incoming and outgoing packets are usually 76 bytes in length.
The NTP time stamp is in the first 48 bytes of the message so you might even be able to ignore everything else.
You could possibly fetch time once a day and use a time library. If the clock on your MKR GSM 1400 is ok, you should not diverge too much from the real time
Thats also my experience, you can't rely on this. NTP (as suggested by J-M-L Jackson) or a regular http get request on a custom made website with the desired time format?