Skip to main content

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 5Raspberry 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.

CommandDescription
AT+QICSGP=1,1,"apn_name","","",1Set PDP context for the FTP connection. Replace apn_name with your operator's APN.
AT+QIACT=1Activate the PDP context.
AT+QIACT?Verify PDP context activation.

FTP Configuration

Configure the FTP session with necessary parameters.

CommandDescription
AT+QFTPCFG="contextid",1Link 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",1Set file type (1 for binary, 0 for ASCII).
AT+QFTPCFG="transmode",1Set transfer mode (1 for passive, 0 for active).
AT+QFTPCFG="rsptimeout",90Set the FTP response timeout (90 seconds).

Opening an FTP Session

Connect to the FTP server and navigate directories.

CommandDescription
AT+QFTPOPEN="ftp.drivehq.com",21Connect 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.

CommandDescription
AT+QFTPPUT="file_name","COM:",0Upload 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+QFTPLENCheck 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.

CommandDescription
AT+QFTPCLOSEClose the FTP session.
AT+QIDEACT=1Deactivate 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

  1. Setup Network Context:
    AT+QICSGP=1,1,"dialogbb","","",1
AT+QIACT=1
AT+QIACT?
  1. 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
  1. Connect to FTP Server:
    AT+QFTPOPEN="ftp.drivehq.com",21
  1. Navigate Directories:
    AT+QFTPCWD="/"
AT+QFTPLIST="."
  1. Upload File:
    AT+QFTPPUT="test_my2.txt","COM:",0
  1. Download File:
    AT+QFTPGET="test_my2.txt","COM:"
  1. 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.

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.

Loading Comments...