I found this sketch in the internet on how to read/set the time in the SIM900 GSM shield:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
int i=0;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(19200);
// set the data rate for the SoftwareSerial port
mySerial.begin(19200);
// mySerial.println( "AT+CCLK =\"14/11/12,10:43:50+08\"");
}
void loop() // run over and over
{
delay(50);
if (mySerial.available())
Serial.write(mySerial.read());
delay(50);
mySerial.println( "AT+CCLK?" );
delay(50);
if (mySerial.available())
Serial.write(mySerial.read());
delay(50);
i++;
if (i==50)
{
mySerial.flush();
i=0;
}
}
I have an issue that everytime the time is read, it doesn't show the whole time, it sometimes leaves some digits out. Please see attached output.
Any help will be highly appreciated.
Also how can I sync the RTC of the SIM900 with network time?
You can set the clock by using SerialRelay to issue the command AT+CCLK ="14/11/12,10:43:50+08" a second or two before the actual time. Or you can adapt a sketch I've seen in the playground somewhere which updates an RTC based on network time. I forget which shield you have but most either have a battery or a large capacitor to keep time when disconnected. If accuracy is important then look at the DS3231 which has a temperature compensated oscillator.
As for reading the time, you know how to read responses from the shield into a character array. Use the same principle here.
QNITZ? You have a SIM900 don't you? That's a command for the Quectel M10.
Any ody tried to use the rtc of sim900 to set the clock (timmer) of the arduino uno? The issue is that the answer of the At commant tomread the rtc is complex to use to set the time.