hi all, i have several of the very good seeeduino gprs boards, based on a leonardo i believe with a few added extras, they work great for my purposes. only thing is i cant find out the purpose of the battery on the reverse side, its a cr1220, i presume its for a real time clock, which would be VERY usefull for some of my applications. i cant find any documentation anywhere on it. anyone have any info at all. dont need to do much just init it set the time and read the current time. for alarms and logs etc. any help most appreciated. thanks.
ive actually worked this one out, the rtc is part of the sim800 so you just control it using the normal AT command set.
if anyone needs the code. posting seems to remove the indentation !! you gotta love browser base stuff so compatible
#ifdef _Time_h
void SetTime(bool UseTimeServer)
{
#ifdef GPRS_H
if (!UseTimeServer)
{ // use network time from simcard
char GprsBuff[50];
memset(GprsBuff,char(0),sizeof(GprsBuff));
Sim800Gprs.sendCmd(“AT+CLTS?\r\n”);
Alarm.delay(2000);
Sim800Gprs.readBuffer(GprsBuff,sizeof(GprsBuff),DEFAULT_TIMEOUT);
if((NULL != strstr(GprsBuff,"+CLTS: 0")))
{
Sim800Gprs.sendCmd(“AT+CLTS=1”);
Alarm.delay(2000);
Sim800Gprs.sendCmd(“AT&W”);
Alarm.delay(2000);
ReBootMe();
}
}
else
{ // use internet timeserver
//at+sapbr=3,1,“Contype”,“GPRS”
Sim800Gprs.sendCmd(“AT+SAPBR=3,1,“Contype”,“GPRS”\r\n”);
Alarm.delay(1000);
//at+sapbr=3,1,“APN”,“live.vodafone.com.fj”
Sim800Gprs.sendCmd(“AT+SAPBR=3,1,“APN”,“live.vodafone.com.fj”\r\n”);
Alarm.delay(1000);
//at+cntp=“pool.ntp.org”,48
Sim800Gprs.sendCmd(“AT+CNTP=“pool.ntp.org”,48\r\n”);
//at+sapbr=2,1 display
Alarm.delay(1000);
//at+cntp
Sim800Gprs.sendCmd(“AT+CNTP\r\n”);
//at+cclk? display
Alarm.delay(1000);
}
// format the time for the Alarm module.
unsigned int hr; unsigned int mn; unsigned int sec;
unsigned int dy; unsigned int mnth; unsigned int yr;
unsigned char GprsBuff[50];
unsigned char* cmdbegin;
unsigned char Scratch[3];
memset(GprsBuff,char(0),50);
Sim800Gprs.sendCmd(“AT+CCLK?\r\n”);
delay(2000);
Sim800Gprs.readBuffer(GprsBuff,sizeof(GprsBuff),DEFAULT_TIMEOUT);
cmdbegin = strstr(GprsBuff, “”");
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
yr = atoi(Scratch); cmdbegin = cmdbegin + 3;
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
mnth = atoi(Scratch); cmdbegin = cmdbegin + 3;
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
dy = atoi(Scratch); cmdbegin = cmdbegin + 3;
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
hr = atoi(Scratch); cmdbegin = cmdbegin + 3;
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
mn = atoi(Scratch); cmdbegin = cmdbegin + 3;
memset(Scratch,char(0),3); strncpy(Scratch,cmdbegin + 1,2);
sec = atoi(Scratch); cmdbegin = cmdbegin + 3;
msg(“dy”,dy,1);msg(“mnth”,mnth,1);msg(“yr”,yr,1);
msg(“hr”,hr,1);msg(“mn”,mn,1);msg(“Sec”,sec,1);
setTime(hr,mn,sec,dy,mnth,yr);
#else
setTime(1, 0, 0, 1, 1, 11); // set time to Saturday 1:00:00am Jan 1 2011
#endif
}
#endif