nRF Connect SDK Integration
Integrate your devices with Nordic nRF Connect SDK using Spotflow west module.
Prerequisites
Before you start integrating your Zephyr device with Spotflow, you should make sure you:
- have development environment with nRF Connect SDK v3.0.0 or later (v3.0.2 recommended),
- have established a connection to the internet.
Install Spotflow Device Module
Add the spotflow
module as a west dependency to your west.yml
file.
manifest:
projects:
- name: spotflow
revision: main
path: modules/lib/spotflow
url: https://github.com/spotflow-io/device-sdk
Install the west dependencies using the nRF Connect VS Code extension or by running the following command in your terminal:
west update
Update Kconfig Configuration
To enable Spotflow logging, you need to add the following lines to your prj.conf
file:
CONFIG_LOG=y # Enable Zephyr Logging
CONFIG_SPOTFLOW=y # Enable Spotflow Module
CONFIG_SPOTFLOW_DEVICE_ID="zephyr-device-001" # Set unique identifier of your device
CONFIG_SPOTFLOW_INGEST_KEY="{your-ingest-key}" # Set your Spotflow ingest key
The CONFIG_SPOTFLOW_INGEST_KEY
is a secret key that allows your device to authenticate with Spotflow. You can manage your ingest keys in the ingest keys page.
Use the nRF Connect Logging Macros
Now, you are ready to use the standard nRF Connect logging API to send logs to Spotflow. See a sample usage in the code below:
#include <zephyr/logging/log.h>
// Register the logging module
LOG_MODULE_REGISTER(main);
void main(void)
{
// Ensure the device has an active internet connection.
LOG_INF("Device has booted up successfully.");
for (int i = 1; i <= 5; i++) {
int reading = i * 10;
LOG_INF("Sensor reading %d: %d units", i, reading);
if (reading > 30) LOG_WRN("Reading is above normal. Value: %d.", reading);
}
LOG_INF("Device shutting down.");
}
For more guidance on logging in nRF Connect SDK, please see the nRF Connect SDK documentation.
Run your Application
Now, you are ready to build and flash your application to the device and start sending logs to Spotflow. Use the nRF Connect VS Code extension or run the following commands in your terminal:
west build -b YOUR_BOARD
west flash
Learn more
Guide: Logging with Zephyr
Fundamentals: Logging
Guide: Crash reports with Zephyr
Fundamentals: Crash reports & core dumps
How is this guide?