Electron VBAT clarification

I see that Vbat keeps the ram and RTC alive when power is gone on Electron Module. However, the documentation mentions it is connected to 3.3V internally, is this saying that the entire module will be powered from my backup battery or will only the ram, registers and rtc be powered? I only need to keep the time up to date during power loss.

On the Electron, VBAT is connected to 3V3 via a 0 ohm resistor on the bottom side of the module.

3V3 is generated by the bq24195 PMIC and will be generated as long as there’s power on VIN, USB, or the LiPo battery. It’s separate from the main STM32 processor, so you can still be in deep sleep mode using the lowest possible current and the retained variables and RTC will still be maintained.

The use case for VBAT on the Electron is when you are not using the LiPo, are supplying either Li+ or VIN by an external power supply that is not always turned on, but you still want to preserve the RTC and retained memory. In that case, you need to remove the resistor and supply VBAT separately, such as by a Lithium coin cell or supercap. But this is a pretty unusual situation.

1 Like

Are you saying that if I remove Vin, LIPO and USB and only have Vbatt supplied with 3V (from say a CR2032 battery) that the processor will continue to run but the 3G module and Regulators will not be consuming current?

If this is the case, how do I place STM32 into deep sleep when power is removed? Would I set up code to detect loss of power and switch to low power mode and then when power is detected again I can put micro back into full run mode?

Do you have any example code that does this?

Finally, why would you remove the 0 R resistor? Wouldn’t vBatt then have no connection.


No, the processor won’t run but the RTC and Backup RAM will be kept alive.

Providing you did remove the resistor, otherwise the coin cell would feed back via the 0Ohm resistor probably draining it much faster than without the resistor in place (you’d need to look into the actual schematics to know what would get powered by the coin cell :wink: ).

When power is removed from the core, it can’t deep sleep, it’s just off but when it gets powered up it immediately starts running with the RTC and Backup RAM data still intact and hence the processor can pick up with this as if it woke from deep sleep.

as mentioned

removing the resistor would only break that connection but not the connection from the pin to the µC’s own VBAT pin.
On the other hand - as indicated above -, leaving it in place would cause the battery to power everything that’s directly connected to the 3v3 pin (which can be a lot).
Also removing the resistor makes sure you are not trying to “recharge” the coin cell from 3v3 when the system is powered (which would be a bad idea).

So if you just take the advise to remove the 0Ohm resistor as it was given, the first two questions become irrelevant.

Thanks, that is what I needed. I just want to keep the RTC time/date correct when power lost, saving me having to double-up with an external RTC with its own backup battery.

My project will be receiving records, time/date stamping them and periodically uploading to the particle cloud to be transferred by web hook to my app.

Related to my question about RTC (though strictly this should go in the firmware category), is there a method to obtain network time/date to synch the RTC? I was thinking I would have an init sequence that gets network time/date and set the RTC. Every now and then it can compare the RTC date/time with network and adjust the RTC if needed. This enables the project to reasonably accurately time/date stamp records when network is not available at any point for a while.

Particle.syncTime() would be the easiest way to do that and it’s also called automatically as stated in the docs

But for these cases …

… you can also use Time.setTime() to “inject” any other reliable time from other sources (e.g. GPS).

1 Like