Sensor Logger

Demonstrates how to log timestampped sensor data and transmit this data when connectivity is available

Overview

The Sensor Logger example periodically measures temperature, humidity, and watches for motion events (sudden motion in any direction). This information is stored in a on-device journal in RAM for later transmission. It can be beneficial to store data and transmit it in batch if connectivity to the network might not always be available or to reduce power consumption as the cost of establishing a connection to the network is amortised across many sensor readings.

On devices with multiple LEDS, the application can be configured to provide visual feedback of the sensor reading. LEDs can be configured to light up when the measured temperature is rising and falling. Also, an LED can be used to show when the device is connecting to the Blecon network.

Source Code

The source code for this app is provided in the sensor-default directory of the blecon-oem-device-firmware repository: https://github.com/blecon/blecon-oem-device-firmware/tree/main/apps/sensor-default

Supported Devices

This code supports the following Zephyr board types:

  • kkm_s5_bcn - KKM S5-BCN Smart Beacon

  • mkbnl02sn/nrf54l15/cpuapp- MOKO SMART L02S-BCN Smart Beacon

Configuration Options

Configurations for each board type is found in the configuration sub-directory.

Sensor Measurement and Reporting Frequency

  • SAMPLING_PERIOD_SEC - Configures how frequently the device takes readings from sensors. Defaults to 60s.

  • REPORTING_PERIOD_SEC - Configures the maximum frequency with which the device submits logged data to the cloud. If connectivity is not available when the device requests a connection, the device will continue to request

LED mapping

LED mappings are configured in the app.overlay file for the selected board under the chosen node. In the example, the blecon-led-sampling-1 and blecon-led-sampling-2 properties point to an LED device to select when the temperature is dropping or rising, respectively.

The blecon-led-status property can be assigned to an LED device to configure the LED used to show Blecon status like whether the device is announcing its ID and connected to Blecon.

Blecon LED Status Library

To display Blecon connection status on LEDs, the BLECON_LED_LIB option must be enabled. For devices with limited memory, this library can be disabled to reduce the application's memory footprint.

Receiving Data

The application submits logged data to the Blecon network and the messages it sends can be connected to any integrations you have set up on your network.

Data arrives as events with the namespace sensor and with the method log

A typical log report payload from a device has the following structure (after decoding):

{
    "uptime": 305,
    "battery": 2950,
    "events": [
      {
        "id": 123
        "time": "2025-01-21T22:00:02+00:00",
        "type": "temperature_humidity_update",
        "temperature": 25.82,
        "humidity": 49.05
      }
    ]
}
Field
Description

uptime

device uptime in seconds

battery

device battery voltage in mV

events

list of logged temperature and motion events

Events

Field
Description

id

ID to disambiguate events

time

timestamp of the event

type

temperature_humidity_update , motion_start, motion_stop, or motion_vector

Temperature/Humidity Updates

Field
Description

temperature

Temperature in °C

humidity

% Relative humidity

Motion events

  • motion_start - time movement started

  • motion_stop- time movement ended

  • motion_vector- (x, y, z) acceleration vector of resting position

Last updated