Nv table to spi flash

Hey

I’m transitioning my product from 002 to 003. The major thing for me to get my head around is the SPI Flash memory, and the interaction with it in order to store data during deep sleeps.

Before I was storing data in the nv like
::nv["temp"].append(temp_reading); ::nv["light"].append(light_reading); ::nv["bat"].append(bat.voltage); ::nv["time"].append(time());

But seems like I now have to write directly to memory (no middleware library), which I’m not familiar with. Where do I start in order to not overwrite any squirrel firmware, keep track and append arrays of readings like the above example? Need a push off the cliff here :slight_smile:

Best, Bobby

You can keep using the nv table on 003 if you want; it’s identical to 002 on 003. That may just be the simplest option?

Okay, I actually thought it didn’t have that. My mistake, documentation is fine.
But still I would love to access the extra space for data storage before enabling the power consuming wifi.

So I just have 4KB buffers and try to fill my data into everything after address 112?

There are some libraries to help you with this, eg:

https://www.electricimp.com/docs/libraries/hardware/spiflashfilesystem/

https://www.electricimp.com/docs/libraries/hardware/spiflashlogger/

https://www.electricimp.com/docs/libraries/utilities/serializer/

The hardware.spiflash object “hides” the space that’s reserved for OS use. You get from address zero to hardware.spiflash.size() for your application use, in 4kB pages.

Thanks Hugo :slight_smile: