Page 1 of 1

Battery backed RTC on I2C bus

Posted: Thu Nov 05, 2015 5:51 pm
by scudderfish
Specifically a DS3231 from your favourite internet auction site. The code is here https://github.com/scudderfish/uDS3231 and you can use it like this :-

Code: Select all

MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
Type "help()" for more information.
>>> import time
>>> from DS3231 import DS3231
>>> time.localtime()
(2015, 1, 1, 0, 0, 20, 3, 1)
>>> DS3231().loadTime()
>>> time.localtime()
(2015, 11, 5, 17, 44, 15, 3, 309)
>>> 
Accurate timekeeping without a network connection. Still version 0.1, I need to add error checking to the saveTime() method, and also get the temperature data out of it as you can never have too many temperature sensors.

Regards,
David

Re: Battery backed RTC on I2C bus

Posted: Thu Nov 05, 2015 6:00 pm
by danicampora
Cool! :-)

BTW we have plans for a time.source() method in order to select the time reference. With this, your external RTC class will need to implement a .now() or .time() method, and then you just pass the object to time.source(). This will mean that you don't need to reconfig the internal RTC every time.

Re: Battery backed RTC on I2C bus

Posted: Thu Nov 05, 2015 9:00 pm
by scudderfish
Nice, I'll keep an eye out for the API and implement it.

Regards,
David

Re: Battery backed RTC on I2C bus

Posted: Mon Dec 14, 2015 1:03 am
by willie
Why do you want an external RTC? I thought one of the WiPy's attractions was an onboard one. That DS board is awfully large, too. :(

Re: Battery backed RTC on I2C bus

Posted: Tue Dec 15, 2015 7:29 am
by pythoncoder
For applications requiring long term accuracy. On the WiPy there is an alternative: update the RTC from a timeserver. I plan to use one on a Pyboard which isn't web connected.

Re: Battery backed RTC on I2C bus

Posted: Thu Dec 17, 2015 6:35 pm
by scudderfish
The onboard one is not battery backed and my wipy is ultimately going in my car where power and net connectivity will be intermittent. If it proves useful for someone else then that's quite fine.

Regards,
David

Re: Battery backed RTC on I2C bus

Posted: Wed Jan 06, 2016 10:08 am
by pythoncoder
@scudderfish I've taken the liberty of adapting this for the Pyboard. I also added a mechanism for calibrating the Pyboard's RTC from the DS3231. https://github.com/peterhinch/micropython-samples.git

Re: Battery backed RTC on I2C bus

Posted: Wed Jan 06, 2016 11:54 am
by scudderfish
pythoncoder wrote:@scudderfish I've taken the liberty of adapting this for the Pyboard. I also added a mechanism for calibrating the Pyboard's RTC from the DS3231. https://github.com/peterhinch/micropython-samples.git
Excellent :)

View the latest post

Posted: Thu Feb 25, 2016 1:30 am
by Alonzosmop
Shall use that section. I have some stuff on its way to do some work with some of the old electronics I got around here.

___

XRumer 12.0.16 + SocPlugin: the BEST software for Facebook / VK / Forums / Blogs promotion!