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.

Overview

The AT Client sample acts as a proxy for sending directives to the nRF9160 modem via AT commands. This facilitates the reading of responses or analyzing of events related to the nRF9160 modem. The commands can be initiated 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.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160ns

The sample is configured to compile and run as a non-secure application on nRF91’s Cortex-M33. Therefore, it automatically includes the Secure Partition Manager that prepares the required peripherals to be available for the application.

You can also configure it to use TF-M instead of Secure Partition Manager.

Building and running

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

The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160ns build target. Because of this, it automatically includes the Secure Partition Manager. You can also configure it to use TF-M instead of SPM.

See Building and programming a sample application for information about how to build and program the application.

Testing

After programming the sample to your development kit, test the sample by performing the following steps:

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

  2. Connect to the nRF9160 DK with LTE Link Monitor.

    Note

    Make sure that Automatic requests is enabled in LTE Link Monitor.

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

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

  5. Run the following commands from the LTE Link Monitor 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+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.

    1. Enter the command: AT%XOPERID

      This command returns the network operator ID.

    2. Enter the command: AT%XMONITOR

      This command returns the modem parameters.

    3. Enter the command: AT%XTEMP?

      This command displays the current modem temperature.

    4. Enter the command: AT%CMNG=1

      This command displays a list of all certificates that are stored on your device. If the device has been added to nRF Connect for Cloud, a CA certificate, a client certificate, and a private key with security tag 16842753 (which is the security tag for nRF Connect for Cloud credentials) are displayed.

Sample output

The 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

Dependencies

This sample uses the following nRF Connect SDK libraries:

It uses the following sdk-nrfxlib library:

In addition, it uses the following sample: