Connect and Transfer- FTP on Your Raspberry Pi 4G LTE HAT
Introduction
FTP is useful for Raspberry Pi 4G LTE HAT applications, enabling reliable file transfers between embedded systems and remote servers. It simplifies managing logs, configurations, or data files in IoT and M2M communication setups. With its compatibility and straightforward commands, FTP ensures efficient integration for connected projects.
Prerequisites
Hardware Requirements
Raspberry Pi 5 | Raspberry Pi 4G LTE CAT4 HAT |
---|---|
Software Requirements
If you have not installed relevant drivers and communication tools, please check the guide first:
Additional Requirements
You will need a pre-configured FTP server with the following details:
- Host: For example, https://ftp.drivehq.com or a FileZilla Server.
- Port: 21.
- Username and Password: Credentials required for authentication.
AT Command Reference
Setting Up Network Context
Before starting FTP operations, configure the PDP context for network connectivity.
Command | Description |
---|---|
AT+QICSGP=1,1,"apn_name","","",1 | Set PDP context for the FTP connection. Replace apn_name with your operator's APN. |
AT+QIACT=1 | Activate the PDP context. |
AT+QIACT? | Verify PDP context activation. |
FTP Configuration
Configure the FTP session with necessary parameters.
Command | Description |
---|---|
AT+QFTPCFG="contextid",1 | Link the FTP connection to PDP context 1. |
AT+QFTPCFG="account","username","password" | Set FTP account credentials. Replace username and password with your FTP details. |
AT+QFTPCFG="filetype",1 | Set file type (1 for binary, 0 for ASCII). |
AT+QFTPCFG="transmode",1 | Set transfer mode (1 for passive, 0 for active). |
AT+QFTPCFG="rsptimeout",90 | Set the FTP response timeout (90 seconds). |
Opening an FTP Session
Connect to the FTP server and navigate directories.
Command | Description |
---|---|
AT+QFTPOPEN="ftp.drivehq.com",21 | Connect to the FTP server. Replace ftp.drivehq.com with your server address. |
AT+QFTPCWD="/" | Change to the root directory. |
AT+QFTPLIST="." | List files and directories in the current path. |
File Operations
There are a couple of ways to send and receive files: via USB COM port, RAM, or UFS.
Command | Description |
---|---|
AT+QFTPPUT="file_name","COM:",0 | Upload a file. Replace file_name with the desired name for the file on the server. |
AT+QFTPGET="file_name","COM:" | Download a file. Replace file_name with the file to retrieve from the server. |
AT+QFTPLEN | Check the length of the last file uploaded. |
AT+QFTPSIZE="file_name" | Get the size of a specific file. Replace file_name with the target file's name. |
Closing the FTP Session
End the FTP session and deactivate the PDP context.
Command | Description |
---|---|
AT+QFTPCLOSE | Close the FTP session. |
AT+QIDEACT=1 | Deactivate the PDP context. |
Example Workflow
If you're using Windows, open the WinCOM tool. For Raspberry Pi, launch Minicom by running the following command:
sudo minicom -D /dev/ttyUSB2
Step-by-Step
- Setup Network Context:
AT+QICSGP=1,1,"dialogbb","","",1
AT+QIACT=1
AT+QIACT?
- Configure FTP:
AT+QFTPCFG="contextid",1
AT+QFTPCFG="account","your_username","your_password"
AT+QFTPCFG="filetype",1
AT+QFTPCFG="transmode",1
AT+QFTPCFG="rsptimeout",90
- Connect to FTP Server:
AT+QFTPOPEN="ftp.drivehq.com",21
- Navigate Directories:
AT+QFTPCWD="/"
AT+QFTPLIST="."
- Upload File:
AT+QFTPPUT="test_my2.txt","COM:",0
- Download File:
AT+QFTPGET="test_my2.txt","COM:"
- Close FTP Session:
AT+QFTPCLOSE
AT+QIDEACT=1
Resources
We highly recommend reviewing the Quectel TCP guide for this module, as it covers advanced topics. This guide can help you tailor your IoT project to meet specific requirements.
- [Web Page] FTP Application Guide
Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.