How to store data in flash
tushar44 last edited by
I am modifying the certain parameters at run time via Bluetooth which need to be stored permanently into Lopy module. Please provide method to store data in to flash.
seb last edited by
You can access files on the device's flash just like you would any other file in python:
with open("/flash/my_config.json", 'w') as conf_file: conf_file.write(json.dumps(my_config_dict))
with open("/flash/my_config.json", 'r') as conf_file: my_config_dict = json.loads(conf_file.read())
danielm last edited by
I use JSON file for this. In my application class instance the config is a dictionary. You can call json.dumps() on it and write the result into a file.
Later you can read the string from the file and call json.loads() on the result to "create" config dictionary.
Consider NVS if storing integers is all you need.