Bluetooth: Nordic UART Service Central
This sample demonstrates how to use the Nordic UART Service (NUS) client with a device acting as a Bluetooth® LE central. It uses the NUS client service to send data back and forth between a UART connection and a Bluetooth LE connection, emulating a serial port over Bluetooth LE.
Requirements
The sample supports the following development kits:
The following board variants do not have DFU capabilities:
S145:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice
nRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice
nRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice
PCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice
PCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice
PCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice
The following board variants have DFU capabilities:
S145:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot
nRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot
nRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot
PCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot
PCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcuboot
PCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot
Overview
This sample scans for devices that advertise with the Nordic UART Service (NUS) UUID and initiates a connection when a device is found. When a device is connected, the sample starts the service discovery procedure.
When connected, the sample forwards any data received on the RX pin of the UART 0 peripheral to the Bluetooth LE unit.
In addition, the sample enables peer TX notifications to receive data from the peer.
User interface
- LED 0:
Lit when the device is initialized.
- LED 1:
Lit when a device is connected.
- Button 3:
Disconnects from the peer when pressed.
Note
LEDs are only used in the normal UARTE configuration. In LPUARTE mode, LEDs are disabled to avoid interfering with the RX pin and to allow proper low-power operation.
In LPUARTE mode, LED 1 may appear lit even when no device is connected for some development kits, because it shares a pin with the RX signal; RX activity can toggle the LED, which is expected behavior.
Building and running
This sample can be found under samples/bluetooth/ble_nus_central/ in the Bare Metal folder structure.
For details on how to create, configure, and program a sample, see Getting Started with the samples.
Building and running with LPUARTE
The lpuarte.conf file configures the sample to use the LPUARTE driver for the NUS Client Service.
This is useful for reducing the power consumption.
Add the file to the build configuration in VS Code or as an extra argument to west: -DEXTRA_CONF_FILE="lpuarte.conf".
Testing
You can test the sample in two ways, depending on the selected UART configuration: the default UARTE configuration or the Low Power UARTE (LPUARTE) configuration.
Test the sample using the standard UARTE interface with two devices, one running this sample (Bluetooth: Nordic UART Service Central) and another running the Bluetooth: Nordic UART Service (NUS) sample. This is the default configuration.
Compile and program the application.
Connect the devices to the computer to access UART 0 and UART 1 on both devices. If you use development kits, UART 0 and 1 are forwarded as COM ports (Windows) or ttyACM devices (Linux) after you connect the development kits over USB. One instance is used for logging (if enabled with
CONFIG_LOG), while the other is used for the NUS Client service.Connect to the kit with a terminal emulator (for example, the Serial Terminal app) for both UARTs on both development kits.
Reset the kits.
Observe that the device running the Bluetooth: Nordic UART Service Central sample is configured to connect to
nRF_BM_NUS. You can configure this name using theSAMPLE_TARGET_PERIPHERAL_NAMEKconfig option. For information on how to do this, see Configuring Kconfig.Observe that the device running the Bluetooth: Nordic UART Service (NUS) sample is advertising under the default name
nRF_BM_NUS. You can configure this name using theCONFIG_SAMPLE_BLE_DEVICE_NAMEKconfig option. For information on how to do this, see Configuring Kconfig.Observe that the text
BLE NUS central example started.is printed on the COM listener connected to the device running the Bluetooth: Nordic UART Service Central sample.Observe that the text
BLE NUS sample initializedis printed on the COM listener connected to the device running the Bluetooth: Nordic UART Service (NUS) sample.Write a text in the COM listener running on the computer and press Enter.
Observe that the text is displayed in the second COM listener running on the computer.
Test the sample with the Low Power UARTE (LPUARTE) interface in loopback mode between two devices, one running this sample (Bluetooth: Nordic UART Service Central) and another running the Bluetooth: Nordic UART Service (NUS) sample.
Build the sample with the LPUARTE configuration by adding the extra Kconfig fragment
lpuarte.conf.Flash the sample to your device.
Connect the pins as described below, as defined in the boards
board-config.hheader.LPUARTE pin connections (board-config.h). Development Kit
nRF54L15 DK
nRF54LM20 DK
nRF54LS05 DK
nRF54LV10 DK
LPUARTE TX
P1.11
P1.12
P1.17
P1.17
LPUARTE RX
P1.12
P1.13
P1.18
P1.18
LPUARTE REQ
P0.04
P1.14
P1.19
P1.19
LPUARTE RDY
P1.14
P1.15
P1.20
P1.20
For Two-device setup:
Device 1 LPUARTE TX → Device 2 LPUARTE RX
Device 1 LPUARTE RX → Device 2 LPUARTE TX
Device 1 LPUARTE REQ → Device 2 LPUARTE RDY
Device 1 LPUARTE RDY → Device 2 LPUARTE REQ
Connect GND between both devices.
For Single-device loopback setup:
LPUARTE TX → LPUARTE RX
LPUARTE REQ → LPUARTE RDY
Power on the devices.
Send a message from the device not connected in loopback mode using a terminal emulator. Observe that it is looped back.
Note
With the LPUARTE configuration, the console is used only for application logging and not for NUS data. Output on the NUS LPUARTE TX line is handled as input on the NUS LPUARTE RX line on the same device (loopback) or as NUS input on the other device when using two devices.