Hi,
I am having trouble getting my head around "using" the current date & time obtained from the GSM network. I am using the GSM Shield (Quectel M10) and a UK registered SIM card. I initially used the GSM library, but have since found it easier to use the AT commands instead (I also want to experiment with bluetooth this way too, so learning more will be a bonus!) Here is my current, simple code:
char inData[42];
char inChar;
byte index = 0;
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
Serial1.write("AT+CCLK? \n\r");
}
void loop() { // run over and over
while (Serial1.available() > 0) {
if(index < 41) // One less than the size of the array
{
inChar = Serial1.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
Serial.println(inData);
}
}
And the serial monitor gives:
AT+CCLK?
+CCLK: "16/01/15,12:27
AT+CCLK?
+CCLK: "16/01/15,12:27:
AT+CCLK?
+CCLK: "16/01/15,12:27:2
AT+CCLK?
+CCLK: "16/01/15,12:27:28
AT+CCLK?
+CCLK: "16/01/15,12:27:28+
AT+CCLK?
+CCLK: "16/01/15,12:27:28+0
AT+CCLK?
+CCLK: "16/01/15,12:27:28+00
AT+CCLK?
+CCLK: "16/01/15,12:27:28+00"
I've omitted some at the beginning, but it builds each line one character at a time up until the last line, which it then repeats endlessly.
Now, I understand what my code does and why it gives the output it does, what I'm struggling with is where to take it from here?! Ultimately, I want it to run a 16x2 display showing:
HH:MM DAY(of the week)
DD MMM YYYY
The +00 at the end is timezone correction, I wanted to utilise this also so the clock needs no manual intervention. I've seen the RTC modules that are available, but in my mind, the information I need is already available, I just don't know how to use it...
I have searched, and the threads I've seen have got me to where I am now, I think my main hurdle is understanding the format that the information comes back to me in. I think it's a string, but I could be wrong, I'm sure it's painfully obvious to most :-[
Thanks in advance