How to save something like array on EEPROM of ESP8266 ?

Hi,

I need to save blow variable into ESP8266 EEPROM and read it again . I have tried EEPROM.put and EEPROM.get but was not successful , How to do it ?

IPAddress local_IP(192, 168, 1, 1)

I'd just save it as a 4-byte array and then re-assemble it upon startup.

uint8_t ip_array[] = {192,168,1,1};
IPAddress local_IP(ip_array[0], ip_array[1], ip_array[2], ip_array[3]);

AFAIK EEPROM.put() will be able to write the 4-byte array just like that:

EEPROM.put(ip_array);

Retrieval can be done similarly using EEPROM.get().

Above is obviously not read-to-run code but just some examples to illustrate how it could work.

Your topic has been moved. Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.


You will have to post your code (don't forget to use code tags as described in How to get the best out of this forum). An ESP8266 does not have EEPROM, it's emulated. You need EEPROM.begin(...) and EEPROM.commit() and we can't see if you used that.

Thanks to rsmls. it works now ! but it was really weird to works like that! but thanks .

@sterretje
It was my first post in this forum , sorry about my bad posting and appreciate of your guidance

Great, nice to hear!
Good luck with the remainder of your project.

actually
EEPROM.put(adress, ip_array);

Sorry about the sloppiness, you're entirely right. Thanks for correcting this!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.