Page 1 of 1

Store data temporarily.

Posted: Wed Aug 21, 2019 12:48 pm
by nebenzahl
Hello people!
I would like you to help me decide which way to use to store temporary data on an ESP32.
I will be collecting the GPS location every 5 seconds, and would like to save this data to ESP and after checking the GPRS connection is active, just send it to my webserver.
So I guarantee the location collection and only send it to the webserver when GPRS is up.
How could I store this data in ESP32?

Could it be in TXT files? or using the btree database?

Re: Store data temporarily.

Posted: Wed Aug 21, 2019 1:24 pm
by jimmo
There's probably two decisions you need to make:
1. - Do you want to persist even if the power is turned off?
2 - Is the data best represented as a dictionary

If #1 is yes, then you need to use the filesystem.
If both are yes, then filesystem+btree is a great solution.

With the right choice of key, you can make anything look like a dictionary I guess...but perhaps just appending lines to a list (or a file) is easier.

Re: Store data temporarily.

Posted: Wed Aug 21, 2019 2:29 pm
by nebenzahl
Thank you for your attention.
Helped me a lot.
Power is not important as it has the device turned on with vehicle power all the time.
So I will start to use the list, because I will have several data, ie several columns for each row, and this will be the best option.
It had not occurred to me to store the data in memory.
Using the lists I can use this temporary storage only when needed, ie when GPRS is down.
How much space do I have to store the data?

Re: Store data temporarily.

Posted: Thu Aug 22, 2019 12:28 am
by jimmo
It depends on your board how much heap RAM you have -- if you have a psram/spiram ESP32, then you'll have a lot of RAM.

Use micropython.mem_info() to check -- (this example is for an ESP8266, so your ESP32 will be a lot more than this)

Code: Select all

>> micropython.mem_info()
stack: 2112 out of 8192
GC: total: 37952, used: 5504, free: 32448
 No. of 1-blocks: 34, 2-blocks: 13, max blk sz: 264, max free sz: 2017
(You care about the "GC total" amount).