Keeping time offline? Timestamps in the subway

My project must work in the NYC subway, but it will get a wifi connection at least once a day. I need timestamps while disconnected accurate to about 5 seconds. (It is more important that the intervals between timestamps be correct, so if they are all off by the same amount no big deal.)

I would prefer if the device could be turned on and off while disconnected and still have timestamps. But, it could stay on the whole time if that makes things easier.

Data are saved to an SD card so flash memory is not a worry.

Should I:

  • connect an external RTC
  • Use the built in RTC
  • Use the built in RTC but mod the core so that it is powered by it’s own source?
  • something else?

It’s not clear to me how sparkTime works without an internet connection. Can I still save timestamps on the SD card? Will cutting power to the core while offline reset the internal RTC? I assume yes.

So, I need to connect power to that chip on the bottom? I have a 3v coincell … any photos of how that would work?

Thanks for all the help I’m looking forward to posting this project when it’s done.

OK I’ve found that cutting the power offline will reset the clock. So, I either need a coincell for the internal clock or… just plant to have it on the whole time.

Has this been tested yet?

Just to be sure, are you using the Core or the Photon? The Photon has a VBAT pin, to which you can hook up a battery/supercap to keep the RTC and a small part of memory alive when the main power is out. That might be the easiest solution, since it’s designed for scenarios like that.

Hi @futurebird

The Core does not have the Vbat pin brought out but Photon does–can you move your project to Photon?

1 Like

Hello Community Folks

I am using Photon and Display to show Humidity and Temp along with Time stamp. I needed to make it work offline so I used SYSTEM_Mode(SEMI_AUTOMATIC) Now the code that I complied using WebIDE works but the TIME STAMP roles back to 1999 instead of 2019 when connected to the internet.
How do i display Date Time and Time Zone from on board RTC of Photon so everything works in the SYSTEM_Mode that I need meaning without any Internet connection.

Thanks

When the device is freshly powered up it wouldn’t know what the current time is. In connected mode the Particle cloud would provide that info on initial connect. If that doesn’t happen you need to take care to provide that time to the device.

You can use Time.setTime() to set the RTC to anything you want.
When setting Time.zone() all functions (apart from Time.now()) will give you the time info including your set zone.

Anything else wouldn’t be unlike having a cuckoo clock which had stopped some time ago and when you wind it up at any arbitrary moment you’d expect it to show the correct time without being manually adjusted :wink:

2 Likes