Cellular: SMS
The SMS sample demonstrates how you can send and receive SMS messages with your nRF91 Series device.
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
|
|---|---|---|---|
PCA10153 |
|
||
PCA10090 |
|
||
PCA10171 |
|
For more security, it is recommended to use the */ns variant of the board target.
When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
Overview
The SMS sample registers your nRF91 Series device for SMS service within the nRF91 Series modem using the SMS library. The sample requires an LTE connection.
When the sample starts, it sends an SMS if a recipient phone number is set in the configuration. The sample then receives all the SMS messages and displays the information about the messages including the text that is sent.
Configuration
See Configuring and building for information about how to permanently or temporarily change the configuration.
Configuration options
Check and configure the following configuration option for the sample:
- CONFIG_SMS_SEND_PHONE_NUMBER - Configuration for recipient phone number in international format
The sample configuration is used to set the recipient phone number in international format if you need to send an SMS.
Additional configuration
Check and configure the following mandatory library options that are used by the sample:
Check and configure the following optional library options that are used by the sample:
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/sms in the nRF Connect SDK folder structure.
For more security, it is recommended to use the */ns variant of the board target (see the Requirements section above.)
When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
To build the sample, follow the instructions in 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:
Connect the kit to the computer using a USB cable. The kit is assigned a serial port. Serial ports are referred to as COM ports on Windows, /dev/ttyACM devices on Linux, and /dev/tty devices on macOS. To list Nordic Semiconductor devices connected to your computer together with their serial ports, open a terminal and run the
nrfutil device listcommand. Alternatively, check your operating system’s device manager or its equivalent.Connect to the kit with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.
Observe that the sample shows the UART output from the device. Note that this is an example, and the output need not be identical to your observed output.
Send an SMS message to the number associated with the SIM card that you have placed into your nRF91 Series device.
Note
Not all IoT SIM cards support SMS service. You must check with your operator if the SMS service does not work as expected.
Sample output
The following output is logged in the terminal:
*** Booting Zephyr OS build v2.4.99-ncs1-1818-g54dea0b2b530 ***
SMS sample starting
SMS sample is ready for receiving messages
Sending SMS: number=1234567890, text="SMS sample: testing"
SMS status report received
SMS received:
Time: 21-04-12 15:42:52
Text: 'Testing'
Length: 7
Dependencies
This sample uses the following nRF Connect SDK library:
It uses the following sdk-nrfxlib library:
The sample also uses the following secure firmware component: