"reading" the response to an AT command

Hi All,

Still progressing well with my little weather alert project and trying to slowly add some additional features one by one
Currently I have achieved (with help for some bits!)

  • read temp & humidity from DHT22
  • read anemometer
  • calculate rolling averages of above as required
  • setup and initialise 3G modem
  • send SMS and/or email alerts
  • compare readings against table for generation of alerts
  • send of alert message when conditions meet criteria
  • send all clear message when conditions improve

Now I am trying to add some time based functions (ie sending of hourly emails)

My SIM5216 module has the ability to sync to network time and update its RTC (thats the easy bit), so I should be able to use that info to then set arduino time via time.h and alarm evens via timealarms.h libraries.

To read the time from the module I issue the following AT Command (from a terminal)

AT+CCLK?

and I see a reply of

+CCLK: "14/01/14,10:55:51+42"

OK

Any pointers on how to receive that string and parse out the bits I need so I can use them with time.h library? (ie: just hours & minutes for this app). I'm trying a few bits of code from various posts but cant seem to capture all the string (ie I get the blank line and the "OK" but not the main response from the example shown above)

Regards

Tim

Further to this - after careful analysis of the code I am using to communicate with the 3G module I have worked out how to make it return the entire string in question (and can print it to the console)

Now to parse the data to just get the hours and minutes component.

From what I am reading STRTOK can be used for this purpose but I'm confused on how to implement it?

My string is held in an array "response" and is for example:

+CCLK: "14/01/14,14:00:38+42"

I just need to extract the hours & minutes from this string

Cheers

Stocky

So maybe I dont need STRTOK.........

This is what I have fudged up so far:

char* valPosition = response +  19;
int TimeHours = atoi(valPosition);
int TimeMinutes = atoi(valPosition + 3);    
Serial.print("Time ");
Serial.print(TimeHours);
Serial.print(":");
Serial.println(TimeMinutes);

it works - may or may not be pretty........

Something similar.

http://forum.arduino.cc/index.php?topic=210478.msg1545706#msg1545706