VTF monitoring

The VTF monitoring sample demonstrates how voltage-temperature-frequency (VTF) data is captured and stored for the nRF Wi-Fi® subsystem. The sample monitors battery voltage, die temperature, and crystal oscillator (XO) frequency offset. The Wi-Fi core uses this data to determine when recalibration is required. The VTF monitoring subsystem updates the snapshots on the application core and stores them in a dedicated memory region that the Wi-Fi core can read. This sample runs on the application core and periodically logs the stored channel values.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Board target

nRF7120 DK

nrf7120dk

nrf7120dk/nrf7120/cpuapp

Overview

The sample periodically logs the following VTF monitoring channels:

  • Die temperature - Supplied by the subsystem built-in provider, which reads the SoC internal die temperature sensor.

  • Battery voltage - In the default configuration, the CONFIG_VTF_BATTERY_VOLTAGE_MONITOR Kconfig option is enabled. Live capture for battery voltage is not yet implemented in the subsystem, so the snapshot holds the default value of the Kconfig option.

  • Crystal oscillator (XO) frequency offset - Since the CONFIG_VTF_FREQ_OFFSET_MONITOR Kconfig option is disabled, the snapshot holds the default value of the Kconfig option.

The sample includes a mock provider in the src/mock_battery_provider.c file to demonstrate a custom channel monitoring backend. It registers a channel with VTF_CHANNEL_DEFINE and simulates a battery discharging from 4200 mV to 3300 mV. This shows that a provider can use any data source, such as a fuel gauge library or a register read, as long as it implements the init() and sample() functions described in the subsystem documentation.

Configuration

See Configuring and building for information about how to permanently or temporarily change the configuration.

Devicetree configuration

The board overlay in the boards/nrf7120dk_nrf7120_cpuapp.overlay file configures the following:

  • nordic,vtf-region - Selects the SRAM region where vtf_snapshots are stored.

Custom battery voltage backend

To build the variant that uses the mock battery voltage provider instead of the default backend, disable CONFIG_VTF_BATTERY_VOLTAGE_MONITOR and enable CONFIG_SAMPLE_VTF_CUSTOM_BATTERY_VOLTAGE_MONITOR:

west build -p -b nrf7120dk/nrf7120/cpuapp samples/vtf_monitoring -- -DCONFIG_VTF_BATTERY_VOLTAGE_MONITOR=n -DCONFIG_SAMPLE_VTF_CUSTOM_BATTERY_VOLTAGE_MONITOR=y

In this configuration, the sample logs a decreasing battery voltage until it resets to 4200 mV.

Building and running

To build for the nRF7120 DK, use the nrf7120dk/nrf7120/cpuapp board target. The following is an example of the CLI command:

west build -p -b nrf7120dk/nrf7120/cpuapp samples/vtf_monitoring

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. 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 list command. Alternatively, check your operating system’s device manager or its equivalent.

  2. Connect to the kit with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.

  3. Observe the periodic log output. With the default configuration, the output looks similar to the following example:

    [00:00:00.013,670] <inf> vtf_monitoring_sample: die temp: 25 C
    [00:00:00.013,680] <inf> vtf_monitoring_sample: battery voltage: 3500 mV
    [00:00:00.013,688] <inf> vtf_monitoring_sample: XO offset: 0 ppm
    

    Die temperature reflects live readings from the die temperature sensor. Battery voltage and XO offset show the configured default values.

  4. Build and run the custom battery voltage backend variant and observe that the battery voltage decreases over time.

Dependencies

This sample uses the following nRF Connect SDK subsystem: