Store data temporarily.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
nebenzahl
Posts: 18
Joined: Mon Jul 01, 2019 5:38 pm
Location: Uruguaiana, Brazil
Contact:

Store data temporarily.

Post by nebenzahl » Wed Aug 21, 2019 12:48 pm

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?
Eng. Luiz Nebenzahl

Online
User avatar
jimmo
Posts: 553
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Store data temporarily.

Post by jimmo » Wed Aug 21, 2019 1:24 pm

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.

User avatar
nebenzahl
Posts: 18
Joined: Mon Jul 01, 2019 5:38 pm
Location: Uruguaiana, Brazil
Contact:

Re: Store data temporarily.

Post by nebenzahl » Wed Aug 21, 2019 2:29 pm

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?
Eng. Luiz Nebenzahl

Online
User avatar
jimmo
Posts: 553
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Store data temporarily.

Post by jimmo » Thu Aug 22, 2019 12:28 am

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).

Post Reply