Hi,
I have a standard v1.14 mycropython installation on a spressif dev kit C.
reading the documentation I do not see any specific prerequisites to use this functionality, however dir (esp32) is not listing NVS.
I can't see a way to access this functionality.
Can somebody point me to the right direction ?
Many Thanks
JC
how to use esp32.NVS?
Re: how to use esp32.NVS?
It's a key value store partitioned into namespaces accessed via labels.
To use it effectively for binary data, you'd need to store the length of a blob in an i32.
I assume this is using the 'nvs' partition, and I'm not sure there's really a use case for it for general data given there's plenty of flash available with higher level abstractions for storing data on flash.
e.g. using btree is easier, or a json file, etc.
Code: Select all
>>> nvs_area = NVS('label')
>>> nvs_area.set_i32('key1', 100)
>>> nvs_are.set_blob('key2', b"binary data")
>>> nvs_area.commit()
>>> machine.reset()
>>> nvs_area = NVS('label')
>>> nvs_area.get_i32('key1')
100
>>> x = bytearray(len(b"binary_data"))
>>> nvs_area.get_blob('key2', x)
11
>>> x
b"binary data"
Code: Select all
>>> nvs_area.set_i32('key_len', len(binary_data))
>>> nvs_area.set_blob('key', binary_data)
>>> nvs_area.commit()
>>> retrieved = bytearray(nvs_area.get_i32('key_len'))
>>> nvs_area.get_blob('key', retrieved)
e.g. using btree is easier, or a json file, etc.
Re: how to use esp32.NVS?
in my system...."module object has no attribute 'NVS'"
with 1.14
import esp32
nvs = esp32.NVS("label")
simply fails.
Which system/version are you using ??
with 1.14
import esp32
nvs = esp32.NVS("label")
simply fails.
Which system/version are you using ??
Re: how to use esp32.NVS?
it's in later commits, available if you compile yourself. indicates it will be in future releases, but no guarantee.
Re: how to use esp32.NVS?
I guess it will be on 1.15 soon to be released.
Thanks for clarifying.
Thanks for clarifying.