#Code samples: FTP for Datalogger

Code tips and tricks for beginners
Post Reply
User avatar
Oli
Posts: 88
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 19 times
Been thanked: 58 times
Contact:

#Code samples: FTP for Datalogger

Post by Oli »

This is a functioning demo, it is made very easy for better understanding.

In preparation for the data logger for solar or battery loading measuring device, I think about how I handle the data.

A consideration is the data as a .csv file easy to send to the PC and then analyze with Excel with diagrams, etc.

I have a 32GB SD card on the ESP32, but with Annex interface I can only have 400kb max 1.4MB unscathed up or download, I think the RAM is not enough.(in a large file, many small files are good)

This program generates the data file within the ESP32
5.2MB are 10,000 lines, are 70,000 log entries.

These are then sent to the PC via FTP. It works great, even with even larger files. (At every start it gets 5MB larger)

I hope it helps someone, have fun ...

Code: [Local Link Removed for Guests]

r$ = "     jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--"
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 
r$ = r$ + "jumps over the lazy dogjumps over the lazy dog -- jumps over the lazy dog--" 


wlog "wait for write al lot of Data to test.txt file on SD Card, for 5 MB about 3 minutes"


for z = 0 to 10000
file.append  "/test.txt", Str$(z) + r$ + chr$(13)+ chr$(10)
next z
wlog "wait for copy the .txt file from SD Card to FTP Server, for 5 MB about 1 minute"


wlog bas.ftp$( "192.168.0.111", "a", "a", "/test.txt", "S:\Datenaktiv\FTP")
wlog "finish"
end
A wonderful FTP server in the ZIP
You do not have the required permissions to view the files attached to this post.
User avatar
Electroguard
Posts: 1080
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 364 times
Been thanked: 388 times

Re: #Code samples: FTP for Datalogger

Post by Electroguard »

I recently had the very problem your log generator creates, log files which grew too large.

I had given the esp32 program a safety valve to make it automatically delete the log and reboot if the system ram dropped below a specified threshold.
That worked great, until I upgraded the esp32 to an S2 with 2Mb PSRAM to give it more system memory, with the unfortunate result that the log file grew too large to read into the log variable at startup, so caused bootup crashes every time.

Was a pain in the butt, cos S2 does not have TX and RX to short out for disabling autorun, but eventually caught it ... then added gpio0 interrupt to trap it in future.

The simple log fix was to add another safety valve to prevent the log file getting larger than a specified max.
At the moment it just deletes the existing large log file, but I plan to add SD and create new log files every day based on the date, then add a safety valve to delete the oldest log file(s) whenever flashfree drops below a specified minimum.
User avatar
Oli
Posts: 88
Joined: Tue Feb 09, 2021 10:07 am
Location: Germany, Meissen
Has thanked: 19 times
Been thanked: 58 times
Contact:

Re: #Code samples: FTP for Datalogger

Post by Oli »

please see my post :

[Local Link Removed for Guests]

i have 32GB !

The lifespan of the flash, the writing cycles is also important.
For SD card this is not so important, put a new one in :-)
Of course, that it is not a program loop.
Post Reply