Skip to content

About EEPROM storage #5125

@hzhh110

Description

@hzhh110

Snip20210429_1

What is the maximum number of bytes that can be stored in EEPROM? I found that when I store more than 3,400, it will crash, but in the actual project, I will crash in more than 2,000. After trying many ways, I still can’t solve it. Is there any solution? What about the problem?

DeviceDetails loadDetailsConfig()
{
DeviceDetails config;
int size = sizeof(config);
memset(&config, 0, size);
EEPROM.begin(size);
uint8_t *p = (uint8_t *)(&config);
for (int i = 0; i < size; i++)
{
*(p + i) = EEPROM.read(i);
}
EEPROM.commit();
EEPROM.end();
return config;
}
void saveDetailsConfig(DeviceDetails details)
{
int size = sizeof(details);
EEPROM.begin(size);
uint8_t *p = (uint8_t *)(&details);
for (int i = 0; i < size; i++)
{
EEPROM.write(i, *(p + i));
}
EEPROM.commit();
EEPROM.end();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions