read file on SD with big size

mehrdadco
Posts: 8
Joined: Tue Jun 11, 2019 8:53 am

read file on SD with big size

Postby mehrdadco » Tue Aug 27, 2019 11:43 am

hi
I have a question, maybe someone can help me
I store outputs of several different sensors on one file in SD.
After a day, the file reaches a maximum of about 4 MB in size
I wanted to send this file to my server from the internet (with post.request or FTP client or ... )
My problem is when I want to read this file from SD
file.readstring();
It cannot handle all data on a file and can only hold up to 63kg
at first, I thought that it's on limitation on sending data which that can not send the whole file but after making a file again that I just read I found out that its reading string problem
String cer = fie.readString();
File file = SD.open("/temp.txt");
if (!file) {
writeFile(SD, "/temp.txt", cer.c_str());
}
else {
Serial.println("File already exists");
}
file.close();
What do you think I can do or what way should i use to read a full size of a file?
and if there is a better way to send a file with this size?

MaxVapor
Posts: 8
Joined: Fri Aug 23, 2019 4:52 pm

Re: read file on SD with big size

Postby MaxVapor » Tue Aug 27, 2019 9:40 pm

You have a limited amount of memory to work with so you cannot load the whole file into a string, you need to read the file in chunks and upload to the server.

See an example from the SDK here:
https://github.com/espressif/esp-idf/bl ... e_server.c

mehrdadco
Posts: 8
Joined: Tue Jun 11, 2019 8:53 am

Re: read file on SD with big size

Postby mehrdadco » Thu Aug 29, 2019 9:05 am

that shows me the way THANK YOU

Who is online

Users browsing this forum: Baidu [Spider] and 122 guests