SIM900 FTP Commands
Watch this video if you want to see the live demo,
To communicate with a web server using a FTP account we need a username and password for logging in. In this example i am using my Linux shared hosting which i had purchased for my old company website. If you are having a cPanel software installed on your server you can easily create a FTP account for uploading and downloading a file.
Here is the screen shot of my FTP login credentials,
” alt=”” aria-hidden=”true” />
In the above image you can see that my FTP username is [email protected] and FTP server name is ftp.marsinnovations.in
The password which i had set is valetron
Using the above details i can upload and download any file in my web server.
Once you have all these details, you can start by first setting up the GPRS connection as follows,
Setting up GPRS connection
Set the connection type to GPRS
AT+SAPBR=3,1,”Contype”,”GPRS”
OK
Set the APN to to “www” since i am using a Vodafone SIM card, It might be different for you, and depends on the network
AT+SAPBR=3,1,”APN”,”www”
OK
Enable the GPRS
AT+SAPBR =1,1
OK
Query if the connection is setup properly, if we get back a IP address then we can proceed
AT+SAPBR=2,1
+SAPBR: 1,1,”10.50.210.158″
OK
Uploading a file to the server
We were allocated a IP address and now we can proceed further by setting up the FTP bearer profile identifier
AT+FTPCID=1
OK
Set the FTP server name to which we want to connect, which in my case is ftp.marsinnovations.in
AT+FTPSERV=”ftp.marsinnovations.in”
OK
Set the FTP user name, which in my case is [email protected]
AT+FTPUN=”[email protected]”
OK
Set the FTP password for logging in, which in my case is valetron
AT+FTPPW=”valetron”
OK
Set the file name which we want to upload to the server, which in my case is 1K.txt
AT+FTPPUTNAME=”1K.txt”
OK
Set the path where the file needs to be uploaded, Here a forward slash (“/”) means we are uploading to the root directory of my FTP account
AT+FTPPUTPATH=”/”
OK
Start the FTP put session, by giving this command
AT+FTPPUT=1
OK
The below output from module indicates it is ready for data upload and 1248 is the max length of data that can be sent at a time, It depends on network status
+FTPPUT:1,1,1248
The below command tells the module that we want to send 10 bytes of data
AT+FTPPUT=2,10
The below URC means that it is ready to accept data and we have to start typing in the data. In my case, i have typed Hello12345
+FTPPUT:2,10
Hello12345
The OK response means that it has received the data
OK
The below URC means that it is ready to transfer more data
+FTPPUT:1,1,1248
But we don’t want to transfer more data, So we close the FTP put session by the below command
AT+FTPPUT=2,0
OK
+FTPPUT:1,0
By now should be able to see a file named 1K.txt in your server FTP account root directory with the content Hello12345
Downloading a file from the server
For simplicity we will download the same file we uploaded earlier
We were allocated a IP address and now we can proceed further by setting up the FTP bearer profile identifier
AT+FTPCID=1
OK
Set the FTP server name to which we want to connect, which in my case is ftp.marsinnovations.in
AT+FTPSERV=”ftp.marsinnovations.in”
OK
Set the FTP user name, which in my case is [email protected]
AT+FTPUN=”[email protected]”
OK
Set the FTP password for logging in, which in my case is valetron
AT+FTPPW=”valetron”
OK
Set the file name which we want to download from the server, which is 1K.txt
AT+FTPGETNAME=”1K.txt”
OK
Set the path from where the file needs to be downloaded, Here a forward slash (“/”) means we are downloading from the root directory of my FTP account
AT+FTPGETPATH=”/”
OK
Start the FTP get session, by giving this command
AT+FTPGET=1
OK
The below URC means that data is received and is available for reading
+FTPGET:1,1
The below command instructs the module to read 1024 bytes of data, if there is lesser bytes of data available then it only gives us that much amount of data
AT+FTPGET=2,1024
The below URC means that 10 bytes of data was read, which is printed below as Hello12345, which is the content of the file 1K.txt
+FTPGET:2,10
Hello12345
OK
The below URC means that FTP server session is closed
+FTPGET:1,0
This is how you upload and download files via FTP in SIM900 and SIM800 GSM module also.
Hope it helps someone.
Also see:
- SIM900 DTMF commands
- SIM900 & SIM908 GSM module – Autobaud rate [Solution]
- SIM900 SMS and Call Commands
- SIM900 / SIM800 USSD Code AT Commands – Working example