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.
-
1Your 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.Dave Newton– Dave Newton2021年06月14日 13:09:53 +00:00Commented Jun 14, 2021 at 13:09
-
1arduino.cc/reference/en/libraries/arduino-nvmJuraj– Juraj ♦2021年06月14日 14:26:38 +00:00Commented 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– TommyS2021年06月14日 20:04:18 +00:00Commented 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– TommyS2021年06月16日 02:05:34 +00:00Commented 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– TommyS2021年06月16日 02:10:18 +00:00Commented Jun 16, 2021 at 2:10
1 Answer 1
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.