RTC Backup Battery dies after 2 hours. Tested twice!

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Abraxas
Posts: 16
Joined: Mon Jan 01, 2018 5:53 pm

RTC Backup Battery dies after 2 hours. Tested twice!

Post by Abraxas » Mon Jan 01, 2018 6:10 pm

Today I hooked up a CR2032 coin cell battery to my PyBoard (v1.1) via VBAT and GND, set up a RTC object via the documentation given from the micro python website, and then disconnected power to see how long the battery would last. After about 2 hours the battery died. I thought maybe it was the battery so I tried again with a fresh battery but ended up with the same results. Anyone have any thoughts on what may be going on here?

Thanks!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by dhylands » Mon Jan 01, 2018 6:16 pm

VBAT actually powers the pyboard, just like when its plugged in via USB.

VBACK powers only the RTC circuitry (so the RTC will continue to keep time, but the microcontroller is shut down).

Abraxas
Posts: 16
Joined: Mon Jan 01, 2018 5:53 pm

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by Abraxas » Mon Jan 01, 2018 6:18 pm

Thanks so much for the information! I'll do that!

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by mcauser » Tue Jan 02, 2018 5:47 am

It seems on the PyBoard 1.0 is the pin labelled VBAT is actually VBACK

PyBoard 1.0
VBAT: battery backup input (the pin above X22)
http://micropython.org/resources/pybv10-pinout.jpg

PyBoard 1.1
VBAT: FET protected supply battery input (the square pin, two pins above X23)
VBACK: battery backup input (the pin above X22)
http://micropython.org/resources/pybv11-pinout.jpg

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

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by pythoncoder » Tue Jan 02, 2018 1:23 pm

Indeed. It is confusing.
Peter Hinch
Index to my micropython libraries.

Trönfstar
Posts: 16
Joined: Fri Jun 09, 2017 5:16 am

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by Trönfstar » Mon Mar 19, 2018 10:44 am

Hi everyone!
On my pyboard v1.0 I tried to backup RTC with a '2032' but it doesn't work (connected to inner x22, x24, polarity ok). If I remove the USB power and connect is again the datetime is set back to default >> 2015 and 0h:0m

I use a standalone module to set the datetime tuple by user input (it works fine).

In the main.py the time.localtime() is used to print the time info (hours and minutes) and save it into a log file. These time elements are defined globally. What should I check, measure? Maybe needs to fix few lines in my code? Battery is perfect, I measured it: 2.99 voltage.

Sorry for offtopic, i didn't want to open a new one for this.

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by chuckbook » Mon Mar 19, 2018 11:44 am

What do you get from:

Code: Select all

# run in standalone mode, backup battery attached
import stm
adc = pyb.ADCAll(12, 0x70000)
print('%.2f %08x' % (adc.read_core_vbat(), stm.mem32[stm.RCC+0x70]))

Trönfstar
Posts: 16
Joined: Fri Jun 09, 2017 5:16 am

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by Trönfstar » Mon Mar 19, 2018 5:14 pm

chuckbook wrote:
Mon Mar 19, 2018 11:44 am
What do you get from:

Code: Select all

# run in standalone mode, backup battery attached
import stm
adc = pyb.ADCAll(12, 0x70000)
print('%.2f %08x' % (adc.read_core_vbat(), stm.mem32[stm.RCC+0x70]))

Pyb.ADCALL() takes 1 argument. Taking the preferred 12 bit resolution the result is: [1.50] [00008200] - quiet surprising...
I also checked the adc.read_core_vref(), which is [0.24] - is that normal?

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by chuckbook » Mon Mar 19, 2018 6:19 pm

What is the firmware release you are using?
If the second parameter of ADCAll isn't accepted the firmware release isn't recent enough to support all ADCAll features.
(The second parameter of ADCAll is just a binary bit pattern defining the meaning of 'all'. It defaults to 0xffffffff which includes all of the available analog inputs. 0x70000 means just the analog channels ADC16..ADC18.)

The value of 0x8200 shows that the RTC is clocked by the LSI oscillator (which isn't in the Vbackup domain).
You may try the following code:

Code: Select all

import pyb
rtc = pyb.RTC()
rtc.init()
Be aware that this feature also requires a recent firmware release.
Note:
If you are using a PYBLITE there isn't a 32kHz crystal installed.

Trönfstar
Posts: 16
Joined: Fri Jun 09, 2017 5:16 am

Re: RTC Backup Battery dies after 2 hours. Tested twice!

Post by Trönfstar » Mon Mar 19, 2018 8:43 pm

The firmware release is 1.8.2 - yepp, it’s not the latest...and the hardware is the lite version.
Double hit: You won! :o ;)
Till now I did not notice any disadvantage of this. :twisted:
Hmmm.. I’ll pass utime.time() as a parameter of utime.localtime() and order a pyb v1.1. :)
Thank you for your help! At least I stop to bite my nails. :)

Post Reply