TCPClient Connect Issues on Electron


@rickkas7 I’m testing your FTP upload code after trying out and testing an Arduino FTP port I found on the forum which I tested over the weekend only to find it was not reliable most of the time I tried it to download multiple MB sized files.

Your library works on the Photon I’m testing it on and the number of details it provides is superior which is nice to see what is actually going on.

I see were sending text files full of ASCII info and it’s working perfectly.

Looking at the code it seems that there are no commands for pulling data down from the FTP server right?

I want to download files to an SD card using the SDFAT library ideally. Is that possible with your library?

At a minimum, it looks like this library could be a great way to upload images stored on an SD card using the SDFAT library. Is that possible?

Could I just change the send filename to an actual file on the SD card that the Photon is attached to running the SDFAT library?

Any advice on this is appreciated :slight_smile:


I tested the library and the example works fine.

Do you have any idea what would be required to upload data from an SD card via the SDFAT library to the FTP server instead of uploading the ASCII test code?


@RWB I was using the FTP to download binary and ASCII files from and to the server. I will try and put in the complete project here. CLE.ino is the code that ties it all together and it uses a state engine I wrote to run the FTP and other tasks, See Tasks folder. Sorry I don’t have the time to pull it apart and simplify it but if you can use any of the code feel free to do so. Dropbox link to zip file


Thanks for sharing!

I will give it a try, ideally, I’m attempting to download a large binary file.

I’ll let you know how it goes.


@pNrie Man that’s a big coding project :slight_smile:

Actually, it’s full of goodies, I can tell you have invested a good amount of time creating it.

I see a lot of useful pieces of code in there that is also useful to me.

Thanks again!


Yes there was a good six months of work in it. Unfortunately the Electron in the state it was in was not capable of the job we had in mind. The cellular failed in some instances to work on the Australian Telstra network and because Telstra is impossible to crack we could not determine why. So we have had to go back to Telit modems which we know work on other designs we completed. Also the SIM holder design was not sturdy enough. The new industrial version was tied to Particle’s SIM cards and this was too much of a limitation for us. So I am trying to port the whole project across to one using our own STM micros and Telit modems.


Man, that is a lot of work to put in only to switch over to another platform. I can feel your pain after looking over your code for the last hour.

I can see it’s highly customized for your application. Pulling out the FTP to SD functions is going to take me some time considering my limited coding knowledge but I can pretty much follow what you’re doing in the code.

Do you think the FTP Code has the ability to download 1 gig files from the FTP server or do you think another method would be better? I’m doing this on a Photon, not an Electron.


I was downloading binary firmware files of the order of 50-100K so I don’t know how expandable it was. I was uploading small ascii files which were appending to large files of several meg on the server but it was done incrementally.
The state engine approach was taken to allow the Electron to do other things while the various delays inherent in FTP were progressing. I did a lot of testing with it and that aspect seemed to work ok.
But whether you will get 1GB transfer without error is hard to say, I think it will depend on your cellular strength to a large degree. I used the MD5 routines to check my downloaded files were correct to the bit, you may be able to use that to check the transfer.


You are using wifi, not cellular so you should be more robust. I have a gut feeling that FTP is not the way to go, it adds another layer on top of TCP which is convenient for naming, deleting, appending files and there is no theoretical limit on the size but I would certainly look at other options. Whether you can get a library which runs on Particle though will be an issue. In our new design I am using MQTT more, it is capable of large payloads but not up to 1G


Yea, I get the same feeling that FTP is not the way to go.

I just posted a new thread asking for advice on the best way to do this.

Hoping it’s not to complicated considering it sounds like such a simple task to download a file to the SD card.