CAF: Sensor manager

The sensor manager sample demonstrates the functionality of the CAF: Sensor manager module. It uses the Simulated sensor driver, the sensor manager module, the CAF: Sensor data aggregator module, and the workload simulator module to automatically sample and gather data and then receive and process it in packages.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

Overview

The sample provides simulated input data using Simulated sensor driver. The input data simulates acceleration in X, Y, and Z axes, with the acceleration generated as value of a periodic wave signal. Whenever new data is generated, the CAF: Sensor manager module generates the appropriate sensor_event instances that include the generated data.

The data from the events is then passed to the CAF: Sensor data aggregator module. When the aggregator’s buffer is full, the application sends aggregated data to the workload simulator module (workload_sim). The workload simulator is a custom module used by this sample only. This module handles the data received from the CAF: Sensor data aggregator module, simulates workload on data using k_busy_wait() and notifies the aggregator module when the aggregator buffer can be freed.

Building and running

This sample can be found under samples/caf_sensor_manager in the nRF Connect SDK folder structure.

See Building and programming an application for information about how to build and program the application.

Testing

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

  1. Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

  2. Reset the kit.

  3. Observe that output similar to the following is logged on UART:

    [00:12:* Booting Zephyr OS build v2.7.99-ncs1-2182-gbb39dfe3121a  *
    [00:00:00.258,605] <inf> event_manager: e:module_state_event module:main state:READY
    [00:00:00.258,728] <inf> event_manager: e:module_state_event module:sensor_sim_ctrl state:READY
    [00:00:00.258,850] <inf> event_manager: e:sensor_state_event sensor:accel_sim_xyz state:ACTIVE
    [00:00:00.258,941] <inf> event_manager: e:sensor_data_aggregator_event Send sensor buffer desc: accel_sim_xyz
    [00:00:00.259,033] <inf> event_manager: e: sensor_data_aggregator_release_buffer_event
    [00:00:00.259,124] <inf> event_manager: e:module_state_event module:sensor_manager state:READY
    [00:00:00.458,526] <inf> event_manager: e:sensor_data_aggregator_event Send sensor buffer desc: accel_sim_xyz
    [00:00:00.458,709] <inf> event_manager: e: sensor_data_aggregator_release_buffer_event
    [00:00:00.658,538] <inf> event_manager: e:sensor_data_aggregator_event Send sensor buffer desc: accel_sim_xyz
    [00:00:00.658,721] <inf> event_manager: e: sensor_data_aggregator_release_buffer_event

Dependencies

This sample uses the following nRF Connect SDK libraries:

This sample uses the following nRF Connect SDK drivers: