TinyShield_RTC set date problem with RTC Library Tests

rlw · 4 · 1495

rlw

  • Jr. Member
  • **
    • Posts: 5
    • View Profile
Apologies in advance if this has been covered in another thread, but I can't seem to find a search facility for the forum.

I've downloaded and installed the TinyShield_RTC example code for the [url https://www.tiny-circuits.com/tiny-shield-rtc.html]Tiny Shield Realtime Clock module[/url].

When I try to use "Set Time" function with the RTC Library Tests, the date portion is mangled.

I put some print statements into the set_time() function so I could see how it handles my input.

I entered the following:

  20150912 13:56:45

And I get the response:

Entered date is: -12019840 13:56:45   <====== (This is the output of my Serial.print calls in set_time() )
The current time is 0/8/2047  13:56:45

It looks like it correctly parses the time, but the date is completely munged.

Could the problem be in the overloaded read_int() function?

RLW


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 342
    • View Profile
I uploaded the code example(using Codebender) and when I paste that string(without preceding spaces) I get:

The current time is 9/12/2015  13:56:45

Have you tried it without a RTC board plugged in? Any different? I haven't seen this problem before so I'm curious about what's going on.


rlw

  • Jr. Member
  • **
    • Posts: 5
    • View Profile
Ben,

Thanks for the response.

After I posted my original question, I commented out the read_time() call and hard-coded the time and date into the set_time() function, to prove to myself that the problem was NOT in set_time(). That worked.

I'm using the Arduino 1.6.5 development environment, which has a crude dumb terminal interface. I removed my sledgehammer code and restored the call to read_time(), and this time used a "real" terminal emulator, Anzio Lite, to enter the time/date. That worked, too.

My guess is that when I hit "SEND" on the stock terminal interface, it inserts a newline or LF/CR into the data stream. That may have been picked up by the read_int() and popped into the year variable.

I'm not positive that the stock terminal interface is the problem, but it worked fine using Anzio to communicate with my stack.

BTW, I'm building an infrared "people counter" for use on a bike trail (or in a doorway, where ever one needs to count people!). My stack contains a TinyDuino, the RTC board, a microSD board, and a proto board to connect the infrared detector and a temperature/humidity sensor. I've already built a prototype using a SparkFun Redboard and an RTC-datalogging shield. The Tiny stuff looks like I can do a low-power version I can run for a couple of months off a 5v 3AH portable USB charger, sleeping most of the time, and waking up on an interrupt from the IR sensor to time-stamp an entry into the CSV logfile. I'm going to log IR "hits", timestamp, temp, humidity, and voltage so I can get some long term metrics on how long I can power this thing.

Thanks again for your response,

RLW


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 342
    • View Profile
Interesting, glad you at least have a solution for the serial stuff.

That sounds like a really useful project. With a 3Ah battery, 3 months looks like almost 1.5 mA average draw- should be doable with this hardware, depending on what the IR sensor is doing. Make sure your SD card library is putting the card to sleep- I've had better luck with sdfat library compared to the default SD lib. Let us know if you ever do a writeup about it.


 

SMF spam blocked by CleanTalk