nRF9160: AT Client
The AT Client sample demonstrates the asynchronous serial communication taking place over UART to the nRF9160 modem. The sample enables you to use an external computer or MCU to send AT commands to the LTE-M/NB-IoT modem of your nRF9160 device.
Requirements
The sample supports the following development kit:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10090 |
|
When built for an _ns
build target, the sample is configured to compile and run as a non-secure application.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
Overview
The AT Client sample acts as a proxy for sending directives to the nRF9160 modem using AT commands. This facilitates the reading of responses or analyzing of events related to the nRF9160 modem. You can initiate the commands from a terminal or the LTE Link Monitor, which is an application implemented as part of nRF Connect for Desktop.
For more information on the AT commands, see the AT Commands Reference Guide.
Building and running
This sample can be found under samples/nrf9160/at_client
in the nRF Connect SDK folder structure.
When built as a non-secure firmware image for the _ns
build target, the sample automatically includes the Trusted Firmware-M (TF-M).
See Building and programming an application for information about how to build and program the application and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.
Testing
After programming the sample to your development kit, test it by performing the following steps:
Press the reset button on the nRF9160 DK to reboot the kit and start the AT Client sample.
Connect to the nRF9160 DK with LTE Link Monitor.
Note
Make sure that Automatic requests is enabled in LTE Link Monitor.
Observe that initially the command AT+CFUN? is automatically sent to the modem, which returns a value 4, indicating that the modem is in the offline mode.
Observe that the LTE Link Monitor terminal display also shows AT+CFUN=1 followed by
OK
indicating that the modem has changed to the normal mode.Run the following commands from the LTE Link Monitor terminal:
Enter the command: AT+CFUN?.
This command reads the current functional mode of the modem and triggers the command AT+CFUN=1 which sets the functional mode of the modem to normal.
Enter the command AT+CFUN? into the LTE Link Monitor terminal again.
The UART/Modem/UICC/LTE/PDN indicators in the LTE Link Monitor side panel turn green. This command also automatically launches a series of commands like:
AT+CGSN=1, which displays the product serial identification number (IMEI).
AT+CGMI, which displays the manufacturer name.
AT+CGMM, which displays the model identification name.
AT+CGMR, which displays the revision identification.
AT+CEMODE, which displays the current mode of operation.
Enter the command: AT%XOPERID.
This command returns the network operator ID.
Enter the command: AT%XMONITOR.
This command returns the modem parameters.
Enter the command: AT%XTEMP?.
This command displays the current modem temperature.
Enter the command: AT%CMNG=1.
This command displays a list of all certificates that are stored on your device. If you add the device to nRF Cloud, a CA certificate, a client certificate, and a private key with security tag 16842753 (which is the security tag for nRF Cloud credentials) are displayed.
Sample output
Following is a sample output of the command AT%XMONITOR:
AT%XMONITOR
%XMONITOR: 5,"","","24201","76C1",7,20,"0102DA03",105,6400,53,24,"","11100000","11100000"
OK
References
Dependencies
This sample uses the following nRF Connect SDK libraries:
AT Host which includes:
It uses the following sdk-nrfxlib library:
In addition, it uses the following secure firmware component: