The Quectel EG21-G module supports LTE Cat 1 (4G), UMTS/HSPA+ (3G), and GSM/EDGE/GPRS (2G) cellular connectivity, and features integrated GNSS. Optimized for IoT applications requiring higher bandwidths than the IoT-oriented 3GPP standard Cat-M1 can accommodate, the EG21-G provides data rates of up to 10Mbps down and 5Mbps up.
Learn more about the EG21-G on the Quectel website.
The best way to begin working with the EG21-G is to take advantage of Quectel's UMTS & LTE EVB developer kit. It features powerful tools in an environment specifically designed for the development and testing of cellular and GNSS applications based on any of a variety of Quectel modems, including the EG21-G. Just clip on a test board featuring the modem you're using. The one you need for this guide is the EG21-G-TE-A test board. It's available separately. The kit can be connected to and used with a Windows 10, Linux or macOS computer.
The EVB and the separate test board can be purchased from the following suppliers:
Working with the EVB and EG21-G requires a configured Super SIM. If you haven't set up your Super SIM in the Console, please do so now. The Super SIM First Steps guide has help if you need it.
Slot a Super SIM into the board's SIM holder. It takes a standard mini-sized SIM, or a micro- or nano-SIM first fitted into an adapter:
Fit the EG21-G test board to the top of the EVB, clipping it to the two connectors in the middle of the EVB. You can place it correctly by aligning the metal panel on the underside of the test board with the four arrows printed on the EVB:
Connect one of the larger bundled antennas to the test board's uFL connector, marked MAIN. You will need one of the supplied whip adapters to join board and antenna:
Connect the EVB to your computer with the supplied RS232-USB cable. Connect the cable to the EVB's COM (MAIN) connector:
Connect the EVB to a suitable power source, such as a USB AC adapter, and then turn on the EVB by sliding the POWER switch to the position marked ON on the board:
Press the PWRKEY button once to enable the modem test board:
At this point the board's POWER, STATUS, and NET_MODE LEDs should be lit, and the NET_STA LED should be flashing:
ls /dev/ttyUSB*
— you should see a single device listed: /dev/ttyUSB0
. This is the USB-to-serial device you'll use to communicate with the EVB.minicom
— you will have to install this separately from source or a package manager like apt
— access the board with minicom -o -D /dev/ttyUSB0
.Within minicom
or PuTTY, enter the AT command AT+COPS?
to see which carrier your EG21-G is connected through:
The EG21-G supports LTE Cat-1 FDD in bands 1-5, 7-8, 12-13, 18-20, 25-26, 28, TDD in bands 38-41, and GSM at 850, 900, 1800, and 1900MHz.
If you wish to limit communications to LTE only, i.e., to disable 2G (GSM), issue this command:
AT+QCFG="nwscanmode",3
To instruct the modem to initiate data-centric attachments only — ie., not to make voice-oriented circuit-switched attachments too, which is the default — issue:
AT+QCFG="servicedomain",1
All these settings will be applied immediately.
Issue this AT command first to apply the Super SIM Access Point Name (APN):
AT+CGDCONT=1,"IP","super"
By default, the EG21-G will roam automatically, but you can force this by issuing:
AT+QCFG="roamservice",2
These settings will be applied immediately.
Having set the modem's APN, establish a Packet Data Protocol (PDP) context with the following command:
AT+QIACT=1
The single parameter is the PDP context's ID, in the range 1-16. It should match the first parameter in the above CGDCONT
command.
You can also QIACT
, in its read form, to get the device's data-connection state — and IP address, if the context is active:
1AT+QIACT?2+QIACT: 1,1,1,"100.74.24.186"
The first numeric parameter is the context ID. The second is its state — 1
indicates it is active — and the third is its type: 1
for IPV4 or 2
for IPV6.
Issue the Quectel-specific command
AT+QPING=1,"<TARGET_IP_ADDRESS_OR_NAME>"
to ping a server. Using one of Google's DNS servers as an example, this will yield:
1+QPING: 0,"8.8.8.8",32,172,2552+QPING: 0,"8.8.8.8",32,212,2553+QPING: 0,"8.8.8.8",32,376,2554+QPING: 0,"8.8.8.8",32,174,2555+QPING: 0,4,4,0,172,376,233
To issue an HTTP GET
request using the EG21-G's built-in HTTP client, run the following commands:
AT+QHTTPCFG="contextid",1
AT+QHTTPCFG="responseheader",1
AT+QIACT=1
AT+QHTTPURL=21
This sets the modem to receive, prompted by the output CONNECT
. The first parameter is the number of bytes the modem should expect to receive: it will end input after receiving this number of characters. The value of 21
comes from the URL below. The URL you provide must include the protocol, i.e., http://
.CONNECT
, enter the URL. For example: http://ifconfig.co/ip
GET
request: AT+QHTTPGET
AT+QHTTPREAD
The request will look like this:
1HTTP/1.1 200 OK2Date: Thu, 19 May 2022 09:42:03 GMT3Content-Type: text/plain; charset=utf-84Content-Length: 135Connection: keep-alive6CF-Cache-Status: DYNAMIC7Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=9kzHe%2BCGgSnaBOgrEZS6NVZA%2BRV1RQGBlD5gTX5WQGNFtSd4RPnimFfKpQ5e%2FV4DmTsZcyFOZyG}8NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}9Server: cloudflare10CF-RAY: 70dbe160d822595c-IAD11alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400121344.204.32.391415OK1617+QHTTPREAD: 0
This example uses a service that returns the IP address of the requester.
If you need to provide extra HTTP request headers, such Authorization: Basic <API_KEY>
, or a custom header required by your server, issue
AT+QHTTPCFG="requestheader",1
to tell the modem to use the custom header that you will provide when you make each request. You will need to create a full HTTP request header separated from your request body by the characters <CR><LF>
. Whether you make a POST
or a GET
request, include a byte-count parameter that totals the header plus the body (POST
request) or header alone (GET
request). For example, AT+QHTTPGET=60,512
for a 512-byte header (including the end-of-header <CR><LF>
). The first parameter, 60
, is a timeout. This usually defaults to 60 seconds but must be included if a second parameter is also present.
To issue a secure HTTP GET
request using the EG21-G's built-in HTTP client, you follow the same procedure outlined above but with some extra steps included to configure SSL.
AT+QHTTPCFG="contextid",1
AT+QHTTPCFG="responseheader",1
AT+QIACT=1
AT+QHTTPCFG="sslctxid",1
AT+QSSLCFG="sslversion",1,3
AT+QSSLCFG="ciphersuite",1,0xFFFF
AT+QSSLCFG="seclevel",0
AT+QHTTPURL=70
This sets the modem to receive, prompted by the output CONNECT. The parameter is the number of bytes the modem should expect to receive: it will end input after receiving this number of characters. The value of 70
comes from the URL below. The URL you provide must include the protocol, i.e., https://
.CONNECT
, enter the URL. For example: https://twilio-cms-prod.s3.amazonaws.com/documents/super-sim-test.json
GET
request: AT+QHTTPGET
AT+QHTTPREAD
The request will look something like this:
1HTTP/1.1 200 OK2Date: Thu, 19 May 2022 10:23:25 GMT3Last-Modified: Thu, 19 May 2022 10:05:25 GMT4Accept-Ranges: bytes5Content-Type: application/json6Server: AmazonS37Content-Length: 12889{10"userId": 1,11"id": 5,12"title": "laboriosam mollitia et enim quasi adipisci quia provident illum",13"completed": false }14OK1516+QHTTPREAD: 0
Sending data from the modem to an Internet-hosted API follows the paths outlined above for the HTTP and HTTPS protocols. The key difference is that you call AT+QHTTPOST
instead of AT+QHTTPGET
.
Optionally, the QHTTPOST
command takes a parameter indicating the amount of data you are sending. The modem uses this to read that number of bytes via the UART over which your application is communicating with it — just as it does with the QHTTPURL
command we used earlier. If you are providing a custom HTTP request header, remember to include its length too.
While the EG21-G supports low-power modes for eDRX and PSM, support for these features will vary by visited network and location. The commands to enable each of these settings on the EG21-G are, respectively:
1AT+CEDRXS=12AT+CPSMS=1
Both settings, but especially PSM, can prevent the modem from being accessible through the terminal during its sleep time. It's best to experiment with these features with the modem local. To disable all power saving if needed, send:
1AT+CEDRXS=02AT+CPSMS=0
Keen to find out more about how the Quectel EG21-G cellular module can power your IoT product design? Contact Quectel sales to line up a conversation.
And don't forget, we're always ready to discuss how Super SIM can help you too.