Storage options for electron when in deep sleep

Hi

I’m looking at adding some extra storage to my electron device to log data if the device cannot connect to the cloud. And as the device goes to deep sleep this data is lost each time.

So, i’m looking at adding some persistent storage.
I’ve tried an SD card module - and i can write to that OK.
I’m currently trying an eeprom 1mbit chip : eeprom chip

I’m currently having trouble getting the eeprom to work… not sure my address is correct!

But while googling options I’ve come across eMMC - SD card as chip…

I need to be able to store a variety of data on each entry - it could be upto 250 character long.
Ideally i want to store the data in a formatted string - which is what i would normally post to the cloud
There could be multiple strings stored if the device cannot connect to the cloud ( for what ever reason ) so i’d need to be able to retrieve these easily.

Any help / pointers greatly appreciated.

I prefer to use SPI NOR flash chips and the SPIFFS library.

Originally I used the ISSI IS25LQ080B 1 M x 8-bit chips but now use the Winbond W25Qxx line as they’re less expensive and available in much larger sizes.

3 Likes

Thanks - they look great.
I’m slowly learning about hardware and seen as i have thrown my self in the deep end - its a steep learning curve.

As they can write / read a file which would allow me to keep different data together - they look much easier to handle.
I’m going to order some and give them ago

I have tried to get something working - but i’m so out of my depth with this.
Ideally i’m looking at saving either multiple STRINGS or saving data into different text files.

Any pointers on where to start. Sadly as much as i enjoy learning all of this - its quite a change from my daily programming that i’m not finding the time to really get going.

If you can wait a week or two there will be a new post on storing data on external flash chips, with a new easy-to-use library.

5 Likes

I certainly can wait - thank you.

Hello

I’m trying out your new library - but things are not going that well.

I keep getting the following error
SPIFFS_mount sz:0 logpgsz:0 logblksz:0 perasz:0 addr:00000000 fdsz:128 cachesz:1192
0000008738 [app.spiffs] INFO: mount res=-10025
erase 00000000:4096
erase 00001000:4096

********** lots of the erase lines here ********

erase 000fc000:4096
erase 000fd000:4096
erase 000fe000:4096
erase 000ff000:4096
0000008882 [app.spiffs] INFO: format res=0
SPIFFS_mount sz:1048576 logpgsz:256 logblksz:4096 perasz:4096 addr:00000000 fdsz:128 cachesz:1192
0000008883 [app.spiffs] INFO: mount after format res=-10025
0000008883 [app] INFO: mount res=-10025

I have tried several chips - but none of them are working.

Any suggestions.

thanks

Make sure you use the SpiFlash object for the correct manufacturer.

Enable trace debugging:

SerialLogHandler logHandler(LOG_LEVEL_TRACE);

And enable low-level debug:

fs.withLowLevelDebug()

You’ll probably want to make the volume smaller as it will generate a lot of debugging messages.

The important part is the part slightly before mount returns -10025 to see what data is being read out of the chips.

1 Like

I have added in the fs.withLowLevelDebug() and got the additional information

SPIFFS_mount sz:0 logpgsz:0 logblksz:0 perasz:0 addr:00000000 fdsz:128 cachesz:1192
0000043402 [app.spiffs] TRACE: read addr=0xfc size=2 data=ffff
0000043402 [app.spiffs] TRACE: read addr=0xfe size=2 data=ffff
0000043403 [app.spiffs] TRACE: read addr=0x10fc size=2 data=ffff
0000043403 [app.spiffs] INFO: mount res=-10025
erase 00000000:4096
0000043404 [app.spiffs] TRACE: erase sector addr=0x0 size=4096
0000043451 [app.spiffs] TRACE: write addr=0xfe size=2 data=0000
0000043452 [app.spiffs] TRACE: write addr=0xfc size=2 data=2905

*** lots of erase elements ***

erase 000ff000:4096
0000055314 [app.spiffs] TRACE: erase sector addr=0xff000 size=4096
0000055359 [app.spiffs] TRACE: write addr=0xff0fe size=2 data=0000
0000055359 [app.spiffs] TRACE: write addr=0xff0fc size=2 data=2804
0000055360 [app.spiffs] INFO: format res=0
SPIFFS_mount sz:1048576 logpgsz:256 logblksz:4096 perasz:4096 addr:00000000 fdsz:128 cachesz:1192
0000055361 [app.spiffs] TRACE: read addr=0xfc size=2 data=6904
0000055361 [app.spiffs] TRACE: read addr=0xfe size=2 data=0000
0000055362 [app.spiffs] TRACE: read addr=0x10fc size=2 data=1604
0000055362 [app.spiffs] INFO: mount after format res=-10025
0000055362 [app] INFO: mount res=-10025

That’s not good. You can see that it wrote some data:

0000043451 [app.spiffs] TRACE: write addr=0xfe size=2 data=0000
0000043452 [app.spiffs] TRACE: write addr=0xfc size=2 data=2905

Then when it went to read the data back out, it got different data:

0000055361 [app.spiffs] TRACE: read addr=0xfe size=2 data=0000
0000055361 [app.spiffs] TRACE: read addr=0xfc size=2 data=6904

I’d try the example 1-unittest-SpiFlashRK example directly in the SpiFlashRK library that’s used by SpiffsParticleRK and see if it passes the direct unit test of reading and writing the flash chip.

1 Like

I’ll give them a try now - thanks

I have run the test example and that indicated that it had PASSED various sections.

I’ve then rerun my original copy of your example code and its now out putting the file contents.

I think i have found my mistake and some how did not catch it earlier.

this line
fs.withPhysicalSize(256 * 1024);

I’ve bought the following chips: IS25LQ020B-JNLE : IC FLASH 2M SPI 104MHZ 8SOIC
chips

would the max size for the above be 2028 * 1024 ??? as anything above the 256 has failed and caused the previous issues.

Also thank you so much for reply so quickly and for writing the library in the first place.

@medida, 2MB is 2048 kilobytes. So the line should be fs.withPhysicalSize(2048 * 1024); :wink:

1 Like

ta - that was typo above - that’s what i thought it should be.

I know i can use any size which is smaller - but if i want to change the size i have to erase / format it ( which is fine )

It been a learning battle - but i’m getting there :smile:

1 Like