I want to upload an image via the FTP protocol using an ESP32 microcontroller, the sim7600 modem and an SD card.
The only alternative I know of is to use the command "AT+CFTPPUT" or "AT+CFTPSPUT" and transmit the file through the serial port (serial2).
The "AT+CFTPPUT" and "AT+CFTPSPUT" commands have the condition to modify the file if it contains the <ETX.> and <Ctrl+Z> bytes. Particularly the byte <Ctrl+Z> ("0x1A") the modem interprets it as a end of the FTP data
The problem I have is that the image file has many <ETX.> and <Ctrl+Z> bytes and the FTP communication is end to the first <Ctrl+Z> byte that it finds.
Currently I have fixed the problem by changing the <ETX.> and <Ctrl+Z> bytes to another set of characters, but it is an informal solution and requires extra processing on the server.
I would be grateful if you could help me and find a better solution. Thanks.
Currently I solved the problem of uploading image files via FTP protocol with an ESP32 MCU and an SD card.
The trick is to use the File System (EFS) built into the sim7600 module. Analyzing the EFS I discovered the following structure:
In the table above it can be seen that the usable spaces are the directories E: and F: with their corresponding directory ID 3 and 0
The steps to follow to upload a file from an SD card to an FTP server, using the E: directory, is as follows:
// Transfer the image from SD card to EFS
AT+CFTRANRX="e:/image.jpg",200000 // Transfer a image file to EFS, where 200000 are the bytes to be transmitted
AT+CFTPSSTART // Acquire FTPS protocol stack
AT+CFTPSLOGIN="ftp.myftpserver.com",21,"email@example.com","password",0 //Login the FTPS server
AT+CFTPSLIST // List the items in the directory on FTPS server
AT+CFTPSPUTFILE="image.jpg",3 // Upload a file in module EFS to FTPS server
Note that in the "AT+CFTRANRX" function the directory E: is used and then in "AT+CFTPSPUTFILE" the directory ID 3 is used. See table above.
The same logic applies to download a file via the FTP protocol using the "AT+CFTPSGETFILE" and "AT+CFTRANTX" functions.
It is recommended to use 115200 baud to transfer information between the SD card and the sim7600 module as fast as possible.
I hope this information is useful for others.
Thanks for the useful information.
Before I spent too much time with this, is the file upload/download reasonably fast?
I want to download a .bin file about 1Mb to 1.4Mb and copy to the ESP32 SPIFF memory.
Tried using HTTP get requests character by character and takes about 30 minutes per Mb and didn't work anyway perhaps the same problem with the <ETX.> and <Ctrl+Z> bytes.
Uploading 200kb files using AT+CFTRANRX with 115200 baud takes about 10 seconds. Then uploading the file to the FTP server takes less than 5 seconds.
Uploading the file to the EFS sim7600 memory takes more time than uploading to the FTP server.
Thank you for the quick reply.
That's quite reasonable, better than 30 minutes per Mb.
I'll give this ftp a try.
115200 is default slow rate.
After initialising the modem at 115200 you can up that to a higher rate and re-initialise the serial.
Without hardware RTS / CTS Flow Control I set mine to 921600 on the ESP32.
SerialAT.begin(921600, SERIAL_8N1, MODEM_RX, MODEM_TX);
I'm using TinyGSM library but its a simple AT+IPR command and is temporary, on reboot it defaults to 115200 so no chance of loosing the modem.
Awesome. Share me your results to know the timings with high baud rates.
Hi, Thanks for sharing your insights,
I'm trying to send a .wav file from an esp32 (SDcard or SPIFFS) to Pi server running FTP.
I'm using a Lilygo ESP32 SIM7600 module.
The SD card is connected to the ESP32 via pins:
2 MISO, 13 CS, 14 SCLK, 15 MOSI.
The SIM 7600 is connected to the ESP32 via pins:
4 POWER, 26 TX, 27 RX. See pin out for SIM7000 which is identical pin out for 7600
How do you mount the SD card onto the SIM 7600 e:/ ?
When I use AT+FSCD to check working drive and attempt to change to E:/ I have ERROR returned.
||09:20:09.637 -> AT+FSCD?
||09:20:09.637 -> +FSCD: C:/
||09:20:09.637 -> OK
||09:20:58.689 -> AT+FSCD=E:
||09:20:58.689 -> ERROR
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.