Retained memory support on Gen. 3 devices

Is retained memory supported on Gen 3 devices? It is not mentioned in the Gen 3 docs, but appears to work although not as described in the Gen 2 docs and there is no longer any VBAT pin. Any risks if I use it? I am hoping to use @rickkas7 PublishQueueAsyncRK library on a Boron and this relies on retained memory.

Retained memory and Gen 3 has been mentioned previously but with no follow up for a few months:

As an example, the following code continues incrementing the prior loopCount after a reset, but starts with a random number (not the declared 0) after a power down. The initialisation is not really a problem as it can be initialised separately by checking the reset reason.

#include "Particle.h"


SerialLogHandler logHandler;

retained uint8_t loopCount = 0;

const unsigned long PERIOD_MS = 3000;
unsigned long lastCount = 0;

void setup() {

void loop() {
	if (millis() - lastCount >= PERIOD_MS) {
		lastCount = millis();
    Log("Loops: %i", loopCount);

I believe retained variables have always worked on the Boron ( Post from 6 months ago ).

I’m not sure about the Argon or Xenon. Maybe that’s why the docs don’t go into much detail ?

Thanks @Rftop, I’m just a bit wary using it if it’s undocumented for Gen.3 and doesn’t behave as previously documented. I guess I’ll just risk it :slight_smile:

Dont you need
enabled for it to work?

Hmmm, yes you should (my mistake), and I just tried it again with that line added and the same behaviour is displayed, ie it retains the variable across resets but does not set it to 0 when powered down. So, still uncertain if it is reliable.

Thanks for spotting that!

How long are you leaving it powered down. Could it be that there is enough capacitance to keep the register that maintains the fact that the retained variable should not be re initialized but not enough to actually retain the value.

Hey @johnnyfp, I’ve tried it for up to 1 minute and it makes no difference.

I’ve been using retained memory for a couple of weeks now on a Boron with no apparent adverse effects, so it seems to be usable apart from initialising the variables.