Zephyr Integration
Integrate your Zephyr-based devices using Spotflow west module.
Prerequisites
Before you start integrating your Zephyr device with Spotflow, you should make sure you:
- have development environment with Zephyr 4.1,
- have established a connection to the internet.
When creating a new west workspace, make sure to use Zephyr 4.1, for example, using west init --mr v4.1.0
.
By default, west init checks out the main branch, which may contain changes breaking the build.
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
Then, install the west dependencies using the following command:
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 Zephyr Logging Macros
Now, you can use the standard Zephyr 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 Zephyr, please see the Zephyr Documentation.
Run your Application
Now, you are ready to build and flash your application to the device and start sending logs to Spotflow:
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?