# Clarification on Retained Memory please!

**URL:** <https://community.particle.io/t/clarification-on-retained-memory-please/53387>\
**Category:** General\
**Tags:** photon\
**Created:** [November 19, 2019, 1:33pm UTC](https://community.particle.io/t/clarification-on-retained-memory-please/53387 "2019-11-19T13:33:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [November 19, 2019, 2:10pm UTC](https://community.particle.io/t/clarification-on-retained-memory-please/53387/2 "2019-11-19T14:10:11Z")

</div>

On the Photon only, you may want to connect VBAT to GND if you are not using a coin cell battery or supercap to power VBAT.

The difference is what happens when you power up the Photon the first time. Since there was previously no power, the retained memory contents are uninitialized.

If you connect VBAT to GND, when you first power up the Photon the retained memory will be initialized, either to 0 or to a specific value if the variable has an initializer (usually, see below).

Another technique that I prefer is to not rely on the values being initialized at all, but instead including special values (magic bytes) in retained memory. I use 4 bytes (uint32\_t). If the magic bytes are not set, I assume the retained memory is not set and initialize it manually.

There are many more examples here, including how to save strings. You can't use a String but you can use a character array.

> [@Retained Memory Tips](https://community.particle.io/t/retained-memory-tips/38137):
>
> Retained memory is a feature of the Particle Photon and Electron that allows data to be preserved across reboots. As a quick refresher: | Technique | Fast | Unlimited | Survives | Survives | | | Read/Write | Writes | Reset | No Power | | ------------ | ---------- | --------- | -------- | --------- | | Regular RAM | Yes | Yes | No | No | | EEPROM | No | No | Yes | Yes | | Retained RAM | Yes | Yes …

---

_[View the full topic](https://community.particle.io/t/clarification-on-retained-memory-please/53387)._
