Getting started with the nRF52840 BLE Zephyr RTOS opens access to one of the most capable BLE 5.3 platforms available. Nordic’s nRF52840 combines a 64 MHz Cortex-M4F with 1 MB flash, 256 KB SRAM, USB, and the industry-leading nRF5 radio — and Zephyr RTOS provides a production-ready foundation for Indian wireless product development.
Table of Contents
- Why nRF52840 for BLE Projects
- Zephyr RTOS Introduction
- Development Setup
- First Zephyr Application
- BLE Peripheral with Zephyr
- India Context and Use Cases
- Frequently Asked Questions
Why nRF52840 for BLE Projects
The nRF52840 is Nordic Semiconductor’s flagship SoC with BLE 5.3, Bluetooth Mesh, Thread, Zigbee, IEEE 802.15.4, and NFC support — all from one chip. The 64 MHz Cortex-M4F with FPU handles demanding signal processing alongside radio protocols. USB 2.0 full-speed is built in (no external bridge chip). For production BLE devices in India — healthcare monitors, industrial wireless sensors, smart locks — nRF52840 is the professional choice.
Popular nRF52840 boards available in India: Nordic nRF52840 DK (₹4,000–6,000), Adafruit Feather nRF52840 Express (₹2,500–3,500), and Sparkfun Pro nRF52840 Mini. All run Zephyr RTOS.
Zephyr RTOS Introduction
Zephyr RTOS is a Linux Foundation project designed for resource-constrained devices. It provides a POSIX-like thread model, rich networking stacks (BLE, Thread, Ethernet), device driver framework, and is certified for safety-critical applications. Nordic maintains the nRF Connect SDK (based on Zephyr) as the primary development framework for nRF52840.
Key advantages over Arduino for production nRF52840 development: proper thread model, BLE stack integration, built-in power management, Over-the-Air DFU (Device Firmware Upgrade), and formal safety certifications relevant for Indian medical device development.
Development Setup
# Install nRF Connect SDK and Zephyr (Ubuntu)
# Install VS Code + nRF Connect for VS Code extension
# Then via nRF Connect SDK Manager in VS Code:
# - Install nRF Connect SDK v2.6+
# - Install toolchain (included with SDK manager)
# Or manual setup:
pip3 install west
west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.6.1 nrf
cd nrf && west update
First Zephyr Application
/* Zephyr "Hello World" blink for nRF52840 DK */
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
/* LED0 from Device Tree (green LED on nRF52840 DK) */
#define LED0_NODE DT_ALIAS(led0)
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int main(void) {
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
while (1) {
gpio_pin_toggle_dt(&led);
k_msleep(500); // Zephyr kernel sleep (500 ms)
}
return 0;
}
Build and flash commands:
west build -b nrf52840dk_nrf52840 -- -DCONF_FILE=prj.conf
west flash
west debug # Start debugging session
BLE Peripheral with Zephyr
/* Zephyr BLE peripheral with custom service */
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gatt.h>
/* Custom service UUID */
#define BT_UUID_CUSTOM_SERVICE BT_UUID_128_ENCODE(...)
/* Temperature characteristic - notify supported */
BT_GATT_SERVICE_DEFINE(custom_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_CUSTOM_SERVICE),
BT_GATT_CHARACTERISTIC(BT_UUID_TEMPERATURE,
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY,
BT_GATT_PERM_READ,
read_temp_cb, NULL, &temp_value),
BT_GATT_CCC(ccc_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
);
int main(void) {
bt_enable(NULL);
bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);
}
India Context and Use Cases
- Healthcare: BLE medical devices for Indian hospitals — glucometers, SpO2 monitors, thermometers with Bluetooth connectivity for HIS integration
- Industrial IoT: Wireless sensors in Indian manufacturing (textile mills, pharma plants) with guaranteed BLE 5 range and deterministic timing
- Smart agriculture: BLE mesh networks across Indian farms for soil, weather, and irrigation monitoring
- Asset tracking: BLE tags for logistics and warehouse management in Indian distribution centres
- BIS certification: nRF52840 with Zephyr is on the path to BIS (Bureau of Indian Standards) wireless device certification
Frequently Asked Questions
Is nRF52840 better than ESP32 for BLE?
For production BLE devices, yes. nRF52840 has a better BLE radio (longer range, more connections, lower power), proper BLE stack (SoftDevice), and is used in certified commercial BLE products. ESP32 BLE is good for prototyping but less reliable in high-connection-count or long-range scenarios.
What is the Zephyr Device Tree?
Device Tree is Zephyr’s hardware description system — you describe your board’s hardware (GPIO pins, I2C busses, SPI busses) in a .dts file. Application code accesses hardware via Device Tree macros, making code portable across different boards with the same drivers.
Can I use Arduino IDE for nRF52840?
Yes. Adafruit provides Arduino BSP for nRF52840 boards. It’s simpler than Zephyr but lacks the BLE stack depth, power management, and OTA DFU features of nRF Connect SDK.
Add comment