Persistance Variable in Firmware

Hi,

I’m creating a firmware which will be used by many users that need to save at least 3 variable/data as persistence in the RAK4630

  1. string (length <= 11)
  2. float (latitude with 7 decimals)
  3. float (longitude with 7 decimals)

is there a tutorial/guide to achieve this when programing using platformio? To save/write data and then read it at next boot?

Hello Ricardo,

Are you using RUI3 or the Arduino BSP version?
The methods to store values in the flash are different for the two.

Im only using VSCODE with Platformio , never heard of RUI3 and Arduino BSP.

are this libraries or some way to make programming easier?

If you are using PlatformIO, then you are using the Arduino BSP, it is just called nRF52 Platform there.

I do not have a simple example how to store variables in the flash (in this case using the file system of the nRF52 platform), but you can have a look into flash-nrf52.cpp
There are functions to

  • initialize the file system and read a data structure from it
  • check if the structure is valid
  • write a default structure if the data is invalid
  • have a function to save a data structure to the file system

As this is saved in flash, it is persistence over resets and power cycles.

Great!! after some code “fighting” I got it running… should I share here some basic guidelines for future users?

Sure, you’re welcome to post some tutorial here.