# Persistent Data (eeprom) - RTL8720DN

**URL:** <https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543>\
**Category:** SDK\
**Tags:** rtl872xd\
**Created:** [May 21, 2021, 9:18am UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543 "2021-05-21T09:18:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TBeeren](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/tbeeren/32/272_2.png) [@TBeeren](https://forum.amebaiot.com/u/TBeeren)\
**Post date:** [May 21, 2021, 9:18am UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/1 "2021-05-21T09:18:10Z")

</div>

Hi!

Is there a way in the arduino SDK to read and write to eeprom or save data (persistant) in the memory? I only need a single byte (uint8\_t value) to write to as identifier of the chipset. Thanks!

---

<div class="post-metadata">

**Author:** ![Alphi\_Jiang](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/alphi_jiang/32/379_2.png) [@Alphi\_Jiang](https://forum.amebaiot.com/u/Alphi_Jiang)\
**Post date:** [May 21, 2021, 10:11am UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/2 "2021-05-21T10:11:57Z")

</div>

Do you mean how to use FlashMemory ? or Real EEPROM such as AT24LC01?

The below two functions is use in the our product…  
you can write any number of data into flash

#include \<FlashMemory.h\>

uint8\_t readEERPOM(uint8\_t \*buf,uint8\_t sz) {

FlashMemory.begin(FLASH\_MEMORY\_APP\_BASE, sz);

FlashMemory.read();  
memcpy(buf, &FlashMemory.buf[0],sz);

return 0;  
}

uint8\_t writeEEPROM(uint8\_t \*buf, uint8\_t sz) {

FlashMemory.begin(FLASH\_MEMORY\_APP\_BASE, sz);

memcpy(&FlashMemory.buf[0], buf, sz);

FlashMemory.update(true); //write before ease flash

return 0;  
}

---

<div class="post-metadata">

**Author:** ![TBeeren](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/tbeeren/32/272_2.png) [@TBeeren](https://forum.amebaiot.com/u/TBeeren)\
**Post date:** [May 21, 2021, 11:58am UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/3 "2021-05-21T11:58:01Z")

</div>

Perfect! That’s where i was looking for. But is this included in the SDK from realtek? If so, could you provide me the headers you’re linking (FlashMemory)?

---

<div class="post-metadata">

**Author:** ![Alphi\_Jiang](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/alphi_jiang/32/379_2.png) [@Alphi\_Jiang](https://forum.amebaiot.com/u/Alphi_Jiang)\
**Post date:** [May 21, 2021, 12:13pm UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/4 "2021-05-21T12:13:44Z")

</div>

you only have include as blew header file  
**#include \<FlashMemory.h\>**

FlashMemory is an official API, found in the Arduino example. I just create read/write function based on the FlashMemory

---

<div class="post-metadata">

**Author:** ![TBeeren](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/tbeeren/32/272_2.png) [@TBeeren](https://forum.amebaiot.com/u/TBeeren)\
**Post date:** [May 21, 2021, 12:37pm UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/5 "2021-05-21T12:37:57Z")

</div>

Amazing, got it! Thanks a lot 😁

---

<div class="post-metadata">

**Author:** ![Alphi\_Jiang](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/alphi_jiang/32/379_2.png) [@Alphi\_Jiang](https://forum.amebaiot.com/u/Alphi_Jiang)\
**Post date:** [May 21, 2021, 12:40pm UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/6 "2021-05-21T12:40:45Z")

</div>

you can refer to FlashMemory Example  
 ![Image 5](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/893ac564781ddd3f19164ab14f953d02f4d6489a.png)

---

<div class="post-metadata">

**Author:** ![TBeeren](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/tbeeren/32/272_2.png) [@TBeeren](https://forum.amebaiot.com/u/TBeeren)\
**Post date:** [May 21, 2021, 2:30pm UTC](https://forum.amebaiot.com/t/persistent-data-eeprom-rtl8720dn/543/7 "2021-05-21T14:30:12Z")

</div>

Thanks! Just tested, and works like a charm.  
Have a good day! 🙂
