Skip to main content
Graduate II
February 26, 2024
Solved

Vbat on RTC

  • February 26, 2024
  • 5 replies
  • 13938 views

Hi everyone,

 

I'm using a STWINBX1.

Some documentation say that RTC can be plug to Vbat. In my case, my board won't be plug to current and will only work with a battery.
My question is simple, is RTC can "remember" date and time if the battery run out of energy ?

I read that some RTC on modern computer can work without battery, with a crystal. But I can't find a similar information for my board.

Thanks

 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    Most of STM32 MCUs have Vbat pin on which you can connect a battery or supercapacitor.

    This is an example from STM32L476-EVAL board:

    SofLit_0-1708967906903.png

    If JP12 position is 2-3. Vbat pin is connected to the battery.

    Internally, there is an internal power switch that controls which power supply will feed the backup domain (that includes RTC) and there is a power low level detection mechanism that monitors VDD. If VDD is available, backup domain is powered from VDD, but if the latter is lost, the switch status changes and will let backup domain to be powered from Vbat (battery).

    SofLit_1-1708968161663.png

    PS: you can connect CR2032 to Vbat pin.

    5 replies

    Technical Moderator
    February 26, 2024

    An RTC always requires a power source, even the modern computers you mentioned. There, a 2032 is usually the power source and usually lasts for the entire utilisation time, so that the normal user does not notice its presence.

    Embedded systems therefore also require a power source, for which the VBAT connection is intended. If VBAT is connected directly to VDD for reasons of simplification, the RTC will forget the set time and date information.

    Hope that answers your question?

    Regards
    /Peter

     

    Graduate II
    February 26, 2024

    Thanks !

     

    Super User
    February 26, 2024

    As an alternative to battery, in some cases a supercapacitor can be used (with all the consequences - limited run time and requirement to charge, mainly).

    JW

    Graduate II
    February 26, 2024

    Thanks you so much for this accurate answer !

    I definitely need to work on my electronics skills in order to design my software

    Graduate II
    February 27, 2024

    My board contain a battery. I checked the power supply schemes of my MCU and

    "VBAT is the power supply for RTC, (through power switch) when VDD is not present."

    There is no mention of external voltage source.

    So if I understand, If I can't add CR2032 (or equivalent), I can't have guarantee to hold date/time if my battery run out of energy ?

    Technical Moderator
    February 27, 2024

    You said you're using STWINBX1 board.

    After checking its schematics, and unfortunately for you, VBAT is tied to VDD in the PCB:

    SofLit_0-1709029111898.png

    So if the VDD is lost you lose the time and date.

    You said your board have a battery.. It could be to power all the board not Vbat pin. So you need in that case to guarantee that the battery keep feeding the system to prevent losing time and date.

    Above I'm talking about a battery that could be connected to Vbat pin.

    Hope I answered all of your questions.

    Graduate II
    March 4, 2024

    Hello,

    I'm looking for a way of keeping correct timestamp even if Vbat is not powering anymore the board.

    I checked online solutions to find a way to "secure" the timestamp if Vbat is out of power.

    So, I know that if Vbat is down, I lose timestamp. But I'm looking for solutions to retrieve a correct timestamp when Vbat is reloaded.

    - HTTP API call ?

    - Provide a new timestamp from a phone with bluetooth ?

    My ideas seems a bit complicated (as they use WiFi or BLE...), and I dont find anything online.

    Is there known method for this type of problem ?

    I want to create a consistant solution which require the minimum of effort to the user. 

    Technical Moderator
    March 4, 2024

    Hello,

    You can use an external RTC module backed up with a battery like these:

    https://learn.adafruit.com/adafruit-pcf8523-real-time-clock/overview

    For this you need an I2C bus communication available on your board.