Getting Started with the nRF7002: Blink an LED Using the nRF Connect SDK

Table of Contents

  1. Introduction
  2. What You Need
  3. Installing the Development Environment
  4. Understanding the nRF7002 Development Kit
  5. Creating Your First Project
  6. Writing the LED Blinking Code
  7. Building and Flashing the Firmware
  8. How the Code Works
  9. Troubleshooting Tips
  10. Conclusion

1. Introduction

The nRF7002 Development Kit combines Nordic Semiconductor’s low-power wireless expertise with the flexibility of the Zephyr RTOS. Powered by the dual-core nRF5340 SoC, this board supports both Wi-Fi and Bluetooth LE. But before diving into advanced features like connectivity and protocols, we’ll start with the simplest task in embedded development: blinking an LED.

Blinking an LED might seem trivial, but it's a rite of passage. It helps you validate that your development environment is working, the board is connected, and you understand basic GPIO control. So let’s get started!


2. What You Need

Here’s what you need to follow along:

  • nRF7002 Development Kit (DK)
  • Micro-USB cable
  • Computer running Windows, macOS, or Linux
  • Visual Studio Code (VS Code)
  • Nordic Semiconductor’s VS Code Extension Pack

3. Installing the Development Environment Using VS Code

Instead of using nRF Connect for Desktop, we’ll set everything up directly inside Visual Studio Code.

Step 1: Install VS Code

Download and install Visual Studio Code from the official website.

Step 2: Install Nordic's VS Code Extensions

Open VS Code and go to the Extensions view. Search for and install the "Nordic Semiconductor Extension Pack", which includes:

  • nRF Connect for VS Code
  • nRF Terminal
  • nRF DeviceTree
  • nRF KConfig
  • C/C++
  • GNU Link Map files

Step 3: Set Up the SDK and Toolchain

In the nRF Connect sidebar tab inside VS Code, go to "Toolchains" and install an SDK version such as v2.9.1. This will include Zephyr RTOS and the required build tools like west, CMake, and Ninja.

After installing the SDK and toolchain, set them as the default in VS Code. You’re now ready to create your project.


4. Understanding the nRF7002 Development Kit and the Devicetree

The nRF7002 DK is built around the nRF5340 SoC, which includes two ARM Cortex-M33 cores:

  • Application core (CPUAPP)
  • Network core (CPUNET)

For this tutorial, we’ll use the application core, since we are just blinking an LED.

What is a Devicetree?

Zephyr uses a system called the Devicetree to describe the board’s hardware layout—things like which GPIO pins are connected to LEDs, buttons, sensors, etc.

Instead of hardcoding pin numbers in your application, Zephyr applications use logical aliases like led0, which are mapped to physical pins in board-specific .dts files. This abstraction makes your code cleaner and easier to port between different boards.

Your code can then refer to led0 without needing to know the actual GPIO number or port. This reference is resolved using macros like DT_ALIAS(led0) and helper functions like GPIO_DT_SPEC_GET.

This approach helps you:

  • Avoid hardcoded values
  • Easily switch to other boards
  • Rely on Zephyr’s validation for pin assignments

Understanding and using the Devicetree correctly is a core part of working with Zephyr and Nordic boards.


5. Creating Your First Project Using VS Code

Now let’s create our first Zephyr application directly within VS Code.

Step 1: Launch VS Code and Select the SDK

Open VS Code and click on the "nRF Connect" icon in the sidebar. Set your preferred SDK version (e.g., v2.9.1) and select a toolchain.

Step 2: Create a New Application

Click "Create a new application" in the sidebar. In the dialog:

  • Create a blank application (Create a new application with all the basics)
  • Set the application name and location (e.g., ~/my_led_app)

This generates the following structure:

my_led_app/
├── CMakeLists.txt
├── prj.conf
└── src/
    └── main.c

This is now a valid Zephyr application. But we still need to configure it for your specific board…

Step 3: Add a Build Configuration

Once the project is created, click “Add Build Configuration” in the nRF Connect panel. This is where you define how Zephyr will build your app.

You’ll be prompted to enter:

  • SDK: Choose nRF Connect SDK v2.9.1
  • Toolchain: Choose nRF Connect SDK Toolchain v2.9.1
  • Board target: Choose Nordic Kits, nrf7002dk/nrf5350/cpuapp/ns. This tells Zephyr to compile the firmware for the application core of your dev kit.
  • Build Directory: You can leave this as the default, or customize it (e.g., build/ inside your project directory).

Click Generate and Build to finish.

What Is a Build Configuration?

A build configuration defines:

  • Which board your app is compiled for
  • Which source files and configs are used
  • Where to store build output (like binaries)
  • Optional overlay files or extra settings

You can create multiple configurations for the same app:

  • One for nrf52840dk_nrf52840
  • One for nrf7002dk_nrf5340_cpuapp
  • One with debugging enabled

This is especially useful when developing cross-platform or multi-core firmware.

Once the configuration is set, the extension uses CMake and Ninja (included in the SDK) to generate the build system.

Now that your project is created and configured, you're ready to write some code!


6. Writing the LED Blinking Code

Let’s now write the code to blink the onboard LED.

prj.conf

CONFIG_GPIO=y

This tells Zephyr to enable the GPIO driver.

src/main.c

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>

#define LED0_NODE DT_ALIAS(led0)
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);

int main(void)
{
    if (!device_is_ready(led.port)) {
        return 0;
    }

    gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);

    while (1) {
        gpio_pin_toggle_dt(&led);
        k_msleep(500);
    }

    return 0;
}

7. Building and Flashing the Firmware

Step 1: Build

Use the "Build" button in the VS Code nRF Connect panel.

Step 2: Flash

Make sure the board is connected via USB. Then click "Flash" in the VS Code interface.

The LED should now blink at a 500ms interval!


8. How the Code Works

Let’s break it down:

  • DT_ALIAS(led0) retrieves the logical alias for the LED.
  • GPIO_DT_SPEC_GET(...) extracts the port, pin, and flags.
  • device_is_ready(...) ensures the GPIO driver is ready.
  • gpio_pin_configure_dt sets the pin to output mode.
  • Inside the loop, gpio_pin_toggle_dt flips the LED on/off.
  • k_msleep(500) delays the toggle for half a second.

This creates the classic blink pattern using Zephyr's device and GPIO APIs.


10. Conclusion

You’ve successfully built and flashed your first embedded application on the nRF7002 Development Kit using the nRF Connect SDK and Zephyr RTOS—all inside VS Code!

This blinking LED may seem simple, but it represents a powerful start. You’ve learned how to set up the environment, configure GPIO through the Devicetree, write application code, and interact with real hardware.

From here, you can explore:

  • Handling button inputs
  • Communicating over I2C/SPI
  • Using the network core for Wi-Fi or Bluetooth
  • Power management features
  • Over-the-air firmware updates

Master the fundamentals, and you’ll be well on your way to building sophisticated IoT applications with Nordic’s platform.