Non-Volatile Memory for Properties

There is a memory in which settings that are to be preserved on the board after a new sketch installation can be permanently stored. It is, for example, useful to save settings such as WiFi access data or similar.

The “PropertyEditor” example from the “Arduino-mbed-APIs” library is a small program which can edit these properties. The “PropertyTest” example explains how to use these properties. Properties can be strings or numbers. Several included example programs already use properties.

Some properties such as the LoRa device ID, the ADC reference voltage and the RTC calibration are already permanently stored in the ECO Power, Eagle, LongRa (starting with rev. 7.5) and Turtle board during production.

There are three locations where properties are stored:

  • OTP memory – can only be programmed once
    Usually the OTP memory is very small, so only a small amount of data can be stored here. Often this type of memory is only used by the hardware manufacturers. The OTP is currently only available for the ECO Power and Eagle boards
  • Flash memory – stores data that are to be preserved (non-volatile)
    The flash memory is also limited in size; usually only a few kilobytes are reserved; 16 kB with the ESP32, 1-64 kB with the D21 (default 16 kB). The flash memory may not be written to as often as desired. However, several thousands of write accesses are possible
  • RAM memory – allows storing property values while the program is being executed
    Property values stored in the RAM memory are not preserved after restarting the application

When a property is loaded, it is searched in RAM memory first, then in flash memory, and finally in OTP memory. Hence, a flash property can override the OTP property or the flash property is found first.

There are properties that are already internally reserved by the system and others which can be added by the user.

Already reserved properties

Many reserved properties are not yet set and can be set by a program or by use of “PropertyEditor”, if required.

You may also define and use your own properties (starting with #128). How this works is shown in the “PropertyEditor” example. All properties are internally listed as “enum” and are comprised of number and name.

A description of the API can be found in the “NVProperty.h” file, in the “Arduino-mbed-APIs” (ECO Power, Eagle and LongRa) and “Turtle_RadioShuttle/NVProperty” (Turtle) library. The “PropertyTest” example may be helpful for learning how to set properties.

Currently, the Property APIs are available for the ECO Power, Eagle, LongRa, and Turtle boards.

PropertyIDTypeDefault
RTC_AGING_CAL1T_8BITpreset
ADC_VREF2T_8BITpreset
HARDWARE_REV3T_8BIT0
LORA_DEVICE_ID10T_32BITpreset
LORA_CODE_ID11T_32BITpreset
LORA_REMOTE_ID12T_32BITnot set
LORA_REMOTE_ID_ALT13T_32BITnot set
LORA_RADIO_TYPE14T_32BITnot set
LORA_FREQUENCY15T_32BITnot set
LORA_BANDWIDTH16T_32BITnot set
LORA_SPREADING_FACTOR17T_8BITnot set
LORA_TXPOWER18T_8BITnot set
LORA_FREQUENCY_OFFSET19T_32BITnot set
LORA_APP_PWD20T_STRnot set
LORA_APP_PWD_ALT21T_STRnot set
LOC_LONGITUDE25T_STRnot set
LOC_LATITUDE26T_STRnot set
LOC_NAME27T_STRnot set
HOSTNAME28T_STRnot set
WIFI_SSID30T_STRnot set
WIFI_PASSWORD31T_STRnot set
WIFI_SSID_ALT32T_STRnot set
WIFI_PASSWORD_ALT33T_STRnot set
USE_DHCP34T_STRnot set
MAC_ADDR35T_BITnot set
NET_IP_ADDR36T_STRnot set
NET_IP_ROUTER37T_STRnot set
NET_IP_DNS_SERVER38T_STRnot set
NET_IP_DNS_SERVER_ALT39T_STRnot set
NET_NTP_SERVER50T_32BITnot set
NET_NTP_SERVER_ALT51T_32BITnot set
NET_NTP_GMTOFFSET52T_32BITnot set
NET_NTP_DAYLIGHTOFFSET53T_32BITnot set
MQTT_SERVER40T_STRnot set
MQTT_SERVER_ALT41T_STRnot set
MQTT_TOPIC_INFO42T_STRnot set
MQTT_TOPIC_ALARM43T_STRnot set
MQTT_TOPIC_CONTROL44T_STRnot set
MQTT_TOPIC_GATEWAY45T_STRnot set
MQTT_TOPIC_546T_STRnot set
ALARM_STATUS60T_32BITnot set
VOIP_SERVER70T_STRnot set
VOIP_USER71T_STRnot set
VOIP_PASSWORD72T_STRnot set
VOIP_DEVNAME73T_STRnot set
VOIP_DIALNO74T_32BITnot set
VOIP_DIALNO_ALT75T_32BITnot set
PROG_CMDLINE80T_STRnot set
MY_CITY129T_STRnot set

Examples

RTC_AGING_CAL = -10
ADC_VREF = 1121
NET_IP_ADDR = 192.168.1.1
MQTT_SERVER = “mqtt://username:password@domain:port”

Training video: “NV Property”

RadioShuttle NVProperty API for Arduino and Mbed OS