Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: RTC not returning time value
PostPosted: Mon Jul 09, 2012 8:53 pm 

Joined: Thu Mar 08, 2012 11:51 pm
Posts: 63
Location: USA
Our code appears to be working properly, but I cannot seem to get a value returned with RTC.getTime(). It simply returns an empty string.

Here is the setup() function:

Quote:
// setup initialization function
void setup()
{
  // init USB communications
  USB.begin();
  USB.print("\nconfiguring ");
  USB.print(DEF_ID_MOTE);
  USB.println("...");

  // enable RTC, Accelerometer
  ACC.ON();
  USB.println("...set ACC to on");
  delay(300);
  RTC.ON();
  USB.println("...set RTC to on");
  delay(300);
  
  // set the RTC clock
  RTC.setTime("00:01:01:00:12:00:00");
  USB.print("...RTC clock initialized to ");
  USB.println(RTC.getTime());

  // setup complete
  flash_leds(4);
  USB.print("\nstarting...");
  USB.print(DEF_ID_MOTE);
  USB.println("...");
}


In the loop() function, we use the following to print the values to USB...

Quote:
  // get sensor data and send
  cnt++;
  sprintf(aux,"TS[%s] DATA: %d -x:%d,y:%d,z:%d -temp:%d -bat:%d%c",
RTC.getTime(),cnt,ACC.getX(),ACC.getY(),ACC.getZ(),(int)RTC.getTemperature(),PWR.getBatteryLevel(),'%');
  USB.println(aux);


The output from this looks like the following:

Quote:
configuring SF-LOCENV--00001...
...set ACC to on
...set RTC to on
...RTC clock initialized to

starting...SF-LOCENV--00001...
sleeping... 15 sec
handle ACC INTERRUPT...
TS[] DATA: 1 -x:-27,y:32,z:1056 -temp:27 -bat:97%
sleeping... 15 sec
handle RTC INTERRUPT...
TS[] DATA: 2 -x:-27,y:32,z:1056 -temp:27 -bat:97%
sleeping... 15 sec
...


As you can see, the there is no time printed after "...RTC clock initialized to" and nothing in "TS[]" either. It appears that RTC.getTime() returns an empty string.

Has anybody experienced this problem before?

Cheers,
Cryptik


Top
 Profile  
 
 Post subject: Re: RTC not returning time value
PostPosted: Tue Jul 10, 2012 9:24 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7515
Hi Cryptik,

Did you try the RTC examples to check it works properly. In case it does, could you please post how you defined variable 'aux'?

Regards


Top
 Profile  
 
 Post subject: Re: RTC not returning time value
PostPosted: Tue Jul 10, 2012 11:57 pm 

Joined: Thu Mar 08, 2012 11:51 pm
Posts: 63
Location: USA
libelium-dev - thank you for the response... the 'aux' var is defined as

char aux[300];

However, I found out what the problem was. In the setup() routine, I initialized the RTC with the following string:

RTC.setTime("00:01:01:00:12:00:00");

In the string above, the day-of-the-week is out of range. It should be 01 (sunday) instead of 00 (undefined). Once I changed this to 01.. the code worked. The problem is not in the RTC but rather in the USB.println() function. Even when the RTC is set with the above string, it still functions correctly with the PWR.deepSleep() function with a 15 second interval. I think that USB.println() does not know what to do with a RTC.getTime() return value when the day-of-the-week is invalid.

Again, thanks for the help.

Cheers,
Cryptik


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 3 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use