1

I have an Arduino program written for the nRF52 with which runs for a pre-set time-value (i.e. 2 minutes) before shuts off automatically. The variable time-value can be changed via BLE-write by the user from an external device (i.e. from 2 mins to 5 mins). The problem that it defaults to the pre-set (2 mins) value once the program restarts. How can I have the program "save" the last used time-value variable (i.e. 5 mins) for the next boot up/restart?

As I understand Nordic's nRF52 does NOT have an onboard EEPROM like AVRs. I read about a Little File System by Adafruit that creates a sort of persistent storage space, but I hope there is something simpler.

5
  • 1
    Your options are the internal flash or an external EEPROM. If you're dealing with the internal flash then some sort of FS is likely the easiest choice. External EEPROM/FRAM can be as simple as an I2C chip and library. LFS doesn't create a "sort of persistent storage space", it's an FS abstration. There's also things like github.com/d00616/arduino-NVM. Jun 14, 2021 at 13:09
  • 1
    arduino.cc/reference/en/libraries/arduino-nvm
    – Juraj
    Jun 14, 2021 at 14:26
  • Thank you both. I am digesting the linked information. Will decide and try. So far, I gathered that I need to be careful with not placing any write/erase related functions inside the "loop" as not to "wear out" the memory.
    – TommyS
    Jun 14, 2021 at 20:04
  • Reviewed the options. Just thinking out loud: Adadfuit already has some QSPI libraries and the chip on their boards. But requires 6 wires (normal SPI 4 wires). NVM is a no-external-parts solution, but does interfere with the nRF5's BLE softdevice stack requiring some fancy programming. I am leaning towards EEPROM and FRAM for ease of addressing/programming, but both require some (small) external real estate. However only a 1 or 2 wire I2C interface.
    – TommyS
    Jun 16, 2021 at 2:05
  • One other options is that upon bootup the sketch on my device would read user-selected values on the connected external BLE device app (phone, ectc) and use them as the variables values in the sketch: for example time-delay selection for auto-off. .
    – TommyS
    Jun 16, 2021 at 2:10

1 Answer 1

2

The arduino-NVM library for nRF51 and nRF52 MCU has EEPROM object which emulates EEPROM in the internal flash memory of MCU.

The EEPROM object in arduino-NVM has the same functions as the EEPROM object in the Arduino EEPROM library for classic ATmega.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.