Cellular: AT Client

The AT Client sample demonstrates the asynchronous serial communication taking place over UART to the cellular 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 nRF91 Series device.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF9161 DK

nrf9161dk_nrf9161

nrf9161dk_nrf9161_ns

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160_ns

When built for an _ns build target, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled. 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 cellular modem using AT commands. This facilitates the reading of responses or analyzing of events related to the cellular modem. You can initiate the commands manually from a terminal such as the nRF Connect Serial Terminal, or visually using the Cellular Monitor app. Both apps are part of nRF Connect for Desktop.

For more information on the AT commands, see the nRF91x1 AT Commands Reference Guide or nRF9160 AT Commands Reference Guide depending on the SiP you are using.

Sending traces over UART on an nRF91 Series DK

To send modem traces over UART on an nRF91 Series DK, configuration must be added for the UART device in the devicetree and Kconfig. This is done by adding the modem trace UART snippet when building and programming.

Use the Cellular Monitor app for capturing and analyzing modem traces.

Building and running

This sample can be found under samples/cellular/at_client in the nRF Connect SDK folder structure.

When built as firmware image for the _ns build target, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE). Because of this, it automatically includes the Trusted Firmware-M (TF-M). To read more about CMSE, see Processing environments.

To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Building and programming an application for other building and programming scenarios 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:

  1. Press the reset button on the nRF91 Series DK to reboot the kit and start the AT Client sample.

  2. Connect to the nRF9160 DK with nRF Connect Serial Terminal.

  3. Run the following commands from the Serial Terminal:

    1. 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.

    2. Enter the command: AT%XOPERID.

      This command returns the network operator ID.

    3. Enter the command: AT%XMONITOR.

      This command returns the modem parameters.

    4. Enter the command: AT%XTEMP?.

      This command displays the current modem temperature.

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

It uses the following sdk-nrfxlib library:

In addition, it uses the following secure firmware component: