Myriota Flex SDK 2.6.0
Loading...
Searching...
No Matches
RF Test Example

This example demonstrates how to read the radio signal strength (RSSI) and display a live monitoring dashboard directly on your serial console.

Build Requirements

To run this example, you must enable RSSI calculation support during the build process. Add the flag -Drssi_calc_support=true to your build settings.

Configuration Options

You can fine-tune the test behavior by modifying the following constants in the example source code:

  • SAMPLES_COUNT: Defaults to 1 to provide rapid screen updates for this demo. Because raw RF signals naturally fluctuate, it is highly recommended to increase this value (e.g., to 5 or 10) for deployments to calculate a stable, accurate average.
  • READ_INTERVAL_MS: The delay (in milliseconds) between consecutive readings.
  • START_DELAY_MS: The initial delay (in milliseconds) before the test begins.

Hardware Compensation

The RSSI values displayed are read directly from the radio chip's receiver and do not account for the RF front-end circuitry.

If you need these readings to perfectly align with calibrated test equipment (such as a signal generator), compensation factors must be applied. Please contact suppo.nosp@m.rt@m.nosp@m.yriot.nosp@m.a.co.nosp@m.m for further information.

Measuring Background Noise

You can use this application to measure ambient background radio noise, which can impact the device's downlink performance.

Mitigating Electrical Interference:

Be aware that standard USB cables and wall power supplies often introduce artificial electrical noise into the system. For the most accurate, real-world environmental test, follow these steps:

  • Ensure SAVE_LOGS is set to 1 in the code to save data directly to the device's non-volatile memory. Note: Ensure all previous logs are cleared from the device before starting the test, otherwise new readings may be dropped.
  • Deploy the device in its intended outdoor location.
  • Retrieve the device and review the logs using DeviceAssist.
#include <stdio.h>
#include "flex.h"
#include "flex_rssi.h"
#define APPLICATION_NAME "RF Test"
// Use the default frequency defined by the SDK for the RSSI check
#define FREQUENCY_HZ FLEX_RSSI_DEFAULT_FREQUENCY_HZ
// ========================================================================
// NOTE ON SAMPLES_COUNT:
// This example uses a SAMPLES_COUNT of 1 strictly for demonstration
// purposes so the terminal updates rapidly with real-time feedback.
// However, raw RF readings can be highly volatile, therefore it is highly
// advised to use a count > 1 (e.g: 5 to 10) to calculate a more stable
// and accurate average RSSI over time.
// ========================================================================
#define SAMPLES_COUNT 1
#define READ_INTERVAL_MS 1000
#define START_DELAY_MS 0
#define SAVE_LOGS 1
static void PrintRFTestResults(const int32_t rssi) {
printf("\033[2J");
printf("\033[H");
printf("\nRF Test Results\n");
printf("--------------------------\n");
printf("%-15s | %-10ld\n", "RSSI (dBm)", rssi);
printf("--------------------------\n\n");
}
static time_t RFTest(void) {
// Ensure the example was built with the required feature flag.
printf("ERROR: please compile with option \"-Drssi_calc_support=true\" to run this example\n");
goto end;
}
// Continuously read and print the RSSI.
// WARNING: A blocking while(1) loop inside a scheduled job will prevent
// other jobs from running. This is acceptable for a dedicated diagnostic application.
while (1) {
const int32_t rssi =
FLEX_RSSIAvgCalcRun(START_DELAY_MS, FREQUENCY_HZ, SAMPLES_COUNT, READ_INTERVAL_MS, SAVE_LOGS);
PrintRFTestResults(rssi);
}
end:
// If we reach here (due to missing support), never run this job again.
return FLEX_Never();
}
void FLEX_AppInit() {
printf("%s\n", APPLICATION_NAME);
}