Cellular: AT Client

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

Board target

Thingy:91 X

PCA20065

thingy91x

thingy91x/nrf9151/ns

nRF9161 DK

PCA10153

nrf9161dk

nrf9161dk/nrf9161/ns

nRF9160 DK

PCA10090

nrf9160dk

nrf9160dk/nrf9160/ns

nRF9151 DK

PCA10171

nrf9151dk

nrf9151dk/nrf9151/ns

When built for a board target with the */ns variant, 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 nRF91 Series modem using AT commands. This facilitates the reading of responses or analyzing of events related to the nRF91 Series 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.

TF-M logging must use the same UART as the application. For more details, see shared TF-M logging.

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 a board target with the */ns variant, 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, follow the instructions in Configuring and building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

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 nRF91 Series 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: