I have been using this IC in my scripts for arduino. I rely on it for any time stuff I have done. Now that I want to port my code to particle photon I wonder how I can to adapt it to work now.
I know that photon has an internatl rtc. I tried and it gives me the correct time as soon as it is connected to the wifi network. But if power is cut off or there is no internet. Time is lost. I see there is a vbat pin but I am not sure if the photon is powered with this pin, wifi still works or not (too much power consuming).
So, now I have my ds3231 powered by a coin battery. I want to have the same in my new device. So I can set the time when I solder the pcb and that’s all. Of course, if internet is available I will take time from there but in case there isn’t (wifi changed and no connection available, power cut…) I want to rely on my own device.
Is there any kind of library or working example around?
If you power the Vbat pin, that should keep the RTC and a small portion of memory (for retained variables) alive if the main power is out. You should be able to use a coin cell or super cap for those purposes
When you say “retained variables” you are not talking about eeprom simulated, are you? I mean, I can remove all power and my “eeprom” variables will be kept for the next time it runs.
In case the vbat works as you say, I think I can remove my ds3231.
Retained variables live in a special area of the SRAM so in normal flow they are used just as any variable, but on power cuts that part of SRAM will be kept via the VBAT supply.
Is there a current library for using external DS3231/DS1307 chips? Most of the effort I see is spent on using the built-in RTC on the Photon (rightly so). I just happen to be using the Photon to control a board that already has a DS3231 with battery backup, and I’d rather use that when offline for extended periods.
UPDATE: I found that this library works well enough.