Is there any form of Persistent Storage or EEPROM emulation for the nrf52840? Need to store around 256 bytes of configuration data, that can survive a power cycle.
I don’t know either, but I’d like to have some NV memory in a XIAO and I found No EEPROM or NVR in XIAO? which suggests that FLASH memory is available, survives power down, but not new code upload. I’ve been using “setup” to hold permanent data but when I need that configuration data to change then I’m hoping I can write to flash. I haven’t yet followed the links in that thread…
I have been successful with using this one with my XIAO BLE SENSE.
Because of another bug I’m looking into with the BLE SENSE I have been saving my Pedometer steps using the above library before putting the SENSE to sleep.
#include <NanoBLEFlashPrefs.h>
struct stepData
{
uint32_t steps; // 4 bytes
};
stepData mySteps = {};
NanoBLEFlashPrefs myFlashPrefs;
In my setup I have this:
// begin initialization
Serial.println("Read record...");
int rc = myFlashPrefs.readPrefs(&mySteps, sizeof(mySteps));
if (rc == FDS_SUCCESS)
{
Serial.println("Preferences found: ");
Serial.println(mySteps.steps);
}
else
{
Serial.print("No preferences found. Return code: ");
Serial.print(rc);
Serial.print(", ");
Serial.println(myFlashPrefs.errorString(rc));
}
and before I put the SENSE to sleep I have this:
Serial.println("Write Steps...");
myFlashPrefs.writePrefs(&mySteps, sizeof(mySteps));
Please note I do get this warning when I compile but everything seems to work as expected.
WARNING: library NanoBLEFlashPrefs claims to run on mbed_nano architecture(s) and may be incompatible with your current board which runs on mbed architecture(s).
-Trey
Hi @Invisibleman1002 , when using the NanoBLEFlashPrefs library I am getting this error :
No such file or directory
4 | #include <fds.h>
Did you face this problem too ?