Battery backed RTC on I2C bus

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
scudderfish
Posts: 24
Joined: Sun Oct 04, 2015 9:06 am

Battery backed RTC on I2C bus

Post by scudderfish » Thu Nov 05, 2015 5:51 pm

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

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Battery backed RTC on I2C bus

Post by danicampora » Thu Nov 05, 2015 6:00 pm

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.

scudderfish
Posts: 24
Joined: Sun Oct 04, 2015 9:06 am

Re: Battery backed RTC on I2C bus

Post by scudderfish » Thu Nov 05, 2015 9:00 pm

Nice, I'll keep an eye out for the API and implement it.

Regards,
David

willie
Posts: 14
Joined: Mon Dec 14, 2015 12:05 am

Re: Battery backed RTC on I2C bus

Post by willie » Mon Dec 14, 2015 1:03 am

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. :(

User avatar
pythoncoder
Posts: 4572
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Battery backed RTC on I2C bus

Post by pythoncoder » Tue Dec 15, 2015 7:29 am

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.
Peter Hinch

scudderfish
Posts: 24
Joined: Sun Oct 04, 2015 9:06 am

Re: Battery backed RTC on I2C bus

Post by scudderfish » Thu Dec 17, 2015 6:35 pm

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

User avatar
pythoncoder
Posts: 4572
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Battery backed RTC on I2C bus

Post by pythoncoder » Wed Jan 06, 2016 10:08 am

@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
Peter Hinch

scudderfish
Posts: 24
Joined: Sun Oct 04, 2015 9:06 am

Re: Battery backed RTC on I2C bus

Post by scudderfish » Wed Jan 06, 2016 11:54 am

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 :)

Alonzosmop
Posts: 1
Joined: Mon Feb 15, 2016 8:12 pm
Location: Tajikistan
Contact:

View the latest post

Post by Alonzosmop » Thu Feb 25, 2016 1:30 am

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!

Post Reply