Quickstart

ESP-IDF Integration

Integrate your ESP-IDF devices using Spotflow module.

Prerequisites

Before you start integrating your ESP-IDF device with Spotflow, you should make sure you:

  • have development environment with ESP-IDF 5.0+ installed,
  • have established a connection to the internet.

Install Spotflow Device Module

Add the spotflow module as a dependency to your idf_component.yml file.

idf_component.yml
dependencies:
    spotflow:
        git: https://github.com/spotflow-io/device-sdk.git
        path: esp_idf/spotflow
        version: main

Update Configuration

To enable Spotflow logging, you need to configure the Spotflow module first. You can do this by running the menuconfig tool and setting the required configuration values:

idf.py menuconfig

Alternatively, you can set these configuration values directly in your sdkconfig.defaults file:

sdkconfig.defaults
CONFIG_SPOTFLOW_DEVICE_ID="esp-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 on the ingest keys page.

Use the ESP-IDF Logging Library

Now, you just need to initialize the Spotflow module and you are ready to use the standard ESP-IDF Logging Library to send logs to Spotflow. See a sample usage in the code below:

src/main.c
#include "esp_log.h"
#include "spotflow.h"

static const char *TAG = "main_module";

void main(void)
{
    // Initialize the Spotflow logging module
    spotflow_init();

    // Ensure the device has an active internet connection.

    ESP_LOGI(TAG, "Device has booted up successfully.");

    for (int i = 1; i <= 5; i++) {
        int reading = i * 10;
        ESP_LOGI(TAG, "Sensor reading %d: %d units", i, reading);
        if (reading > 30) ESP_LOGW(TAG, "Reading is above normal. Value: %d.", reading);
    }

    ESP_LOGI(TAG, "Device shutting down.");
}

Run your Application

Now, you are ready to build and flash your application to the device and start sending logs to Spotflow. Run the following commands in your terminal:

idf.py build
idf.py flash

To view the logs locally on your console, you can use:

idf.py monitor

How is this guide?