Sensor Beacon Application
A Zephyr application that broadcasts onboard sensor data (accelerometer, temperature, humidity) and battery voltage information via Bluetooth beacon advertisements, with BLE connection support for runtime configuration via AT commands.
This application is designed to be used with the Atmosic DevTools mobile app to monitor sensor data. It also exposes an AT command interface over BLE GATT for runtime device configuration.
Overview
The sensor_beacon application provides sensor data collection and broadcasting via Bluetooth beacon advertisements, together with BLE connection support and an AT command interface for runtime configuration. It uses dual extended advertising sets: a non-connectable set that continuously broadcasts sensor data, and a connectable set that allows a BLE central to connect, authenticate, and issue AT commands over GATT.
Using with Atmosic DevTools App
The sensor_beacon application is designed to work with the Atmosic DevTools mobile app for monitoring sensor data and controlling wake-up.
Monitoring Sensor Data
Open the Atmosic DevTools app
Navigate to APPLICATIONS → BEACON
The app will start scanning for devices
When your sensor beacon device appears, tap MONITOR
The app will display real-time sensor data from the device
Features
Sensor Data Collection: Reads temperature, humidity, and 3-axis accelerometer data
Battery Monitoring: Monitors VStore and VBatt voltages
Bluetooth Beacon Advertising: Broadcasts sensor data using a standardized beacon format
BLE Connection Support: Accepts connections on a second advertising set and provides GATT services for AT command transport
AT Command Interface: Runtime configuration of device name, advertising interval, and custom advertising data; settings are persisted to NVS flash
Periodic Updates: Configurable interval for sensor data updates
Power Management: Supports Zephyr power management
Comprehensive Testing: Full Ztest test suite included
Architecture
The application follows a modular design with clear separation of functionalities:
sensor_beacon/
├── src/
│ ├── main.c # Application entry point; BLE connection callbacks
│ ├── sensor_beacon.c # Main application logic and sensor loop
│ ├── sensor_interface.c # Sensor reading with scaling
│ ├── battery_monitor.c # Battery voltage monitoring
│ ├── beacon_adv.c # Dual-set Bluetooth advertising (sensor + connection)
│ ├── beacon_adv_at_cmd.c # AT command extensions with NVS persistence
│ ├── at_gatt.c # GATT service for AT command transport (TXRX characteristic)
│ ├── at_cmd_manager.c # AT command routing and unlock state machine
│ └── sensor_data.c # Periodic sensor data collection
└── tests/ # Comprehensive test suite
Dual advertising sets (both started at boot):
Set 0 — Non-connectable extended advertising (SID 0). Carries the full sensor beacon payload (Eddystone-URL, Manufacturer Data with sensor readings). Interval: 1–1.2 s normal, 100–150 ms fast.
Set 1 — Connectable extended advertising (SID 1). Carries only Flags + Complete Name. Used by a BLE central to connect and interact with the GATT-based AT command interface. Interval: slow (
BT_GAP_ADV_SLOW_INT_MIN/MAX).
Configuration
Key configuration options in prj.conf:
CONFIG_SENSOR_BEACON_UPDATE_INTERVAL: Update interval in centiseconds (default: 100 = 1s)CONFIG_SENSOR_BEACON_FAST_ADV: Enable fast advertising mode for quick device discovery (default: n)CONFIG_BT_EXT_ADV_MAX_ADV_SET: Number of extended advertising sets (default: 2 — one sensor beacon set, one connectable set)CONFIG_ATM_AT_CMD: Enable AT command core framework (default: y)CONFIG_AT_CMD_SET: Enable subsys AT command set (default: y)CONFIG_AT_CMD_LOCK_SET: Enable lock/unlock commands (default: y)CONFIG_SETTINGS/CONFIG_NVS: Persistent storage for device name and user ad data
Beacon Advertising Intervals
The application supports two advertising modes (selected by Kconfig):
Normal Mode (Default): 1-1.2 second intervals for optimal power consumption
Fast Mode: 100-150ms intervals for quick device discovery
To enable fast mode, set CONFIG_SENSOR_BEACON_FAST_ADV=y in your configuration.
Sensor Data Format
The application uses a standardized sensor data format for client compatibility:
typedef struct {
uint16_t temp; // Temperature (scaled by 256)
uint16_t humidity; // Humidity (scaled by 256)
uint16_t x_axis; // X-axis acceleration (scaled)
uint16_t y_axis; // Y-axis acceleration (scaled)
uint16_t z_axis; // Z-axis acceleration (scaled)
float vstore; // Storage voltage (volts)
float vbatt; // Battery voltage (volts)
} __packed sensor_beacon_data_t;
Beacon Advertisement Structure
The sensor beacon advertising set (Set 0, non-connectable) uses the following payload:
Flags:
BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDRComplete Name: Device name (runtime-configurable via
AT+BLEGAPDEVNAME; persisted to NVS)Service UUID: Eddystone UUID (0xFEAA)
Service Data: Eddystone-URL pointing to atmosic.com
Manufacturer Data: Atmosic Company ID (0x0A24) + sensor data
The connectable advertising set (Set 1) carries only:
Flags:
BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDRComplete Name: Device name
AT Command Interface
The sensor_beacon application includes a BLE GATT-based AT command interface that enables
runtime configuration of the device over a Bluetooth LE connection. This feature is enabled by
default in the production configuration (prj.conf).
Prerequisites
AT command support requires the following Kconfig options (all enabled by default in
prj.conf):
CONFIG_ATM_AT_CMD=y— AT command core frameworkCONFIG_AT_CMD_SET=y— Subsys AT command setCONFIG_AT_CMD_LOCK_SET=y— Lock/unlock command setCONFIG_BT_MAX_CONN=2— Allows inbound BLE connections for configurationCONFIG_SETTINGS=y/CONFIG_NVS=y— Persistent storage for settings
Note
When CONFIG_BT_MAX_CONN is set to 2, the device advertises as connectable to
allow BLE GATT-based configuration in addition to broadcasting beacon data.
GATT Service
AT commands are transported over a custom BLE GATT service. Connect to the sensor beacon device and interact with the TXRX characteristic:
Attribute |
Details |
|---|---|
Service |
custom 128-bit UUID |
Characteristic |
TXRX (custom 128-bit UUID) Properties: Write + Notify |
Write the AT command string to the TXRX characteristic to issue a command.
Enable notifications on the TXRX characteristic to receive command responses.
Security — Lock/Unlock Mechanism
The device starts in a locked state on every power-on and on every new BLE connection.
All configuration commands are rejected while locked. Use AT+SYSUNLOCK to unlock.
For the full command reference see System Commands.
Supported AT Commands
Command Syntax
AT commands follow the standard format:
AT+<COMMAND>=<parameter>
The AT+ prefix is case-insensitive.
Command Reference
AT+SYSLOCK
Locks the AT command channel or queries the current lock state. Lock-exempt — can be sent at any time regardless of lock state.
AT+SYSLOCK=ON # Lock the channel
AT+SYSLOCK? # Query lock state
Responses: OK — locked; +SYSLOCK:ON / +SYSLOCK:OFF — query result.
See System Commands for full reference.
AT+SYSUNLOCK
Unlocks the AT command channel. Must be sent before any configuration command. Lock-exempt.
AT+SYSUNLOCK=<key>
Responses: OK — unlocked; ERROR:144 — wrong key.
Note
Default key: atm1atm123 (CONFIG_AT_CMD_SYSUNLOCKKEY_VALUE).
See System Commands for full reference.
AT+BLEGAPDEVNAME
Sets or queries the BLE GAP device name. The new name is immediately reflected in the advertisement and persisted to NVS flash so it survives reboot.
AT+BLEGAPDEVNAME=<name> # Set device name
AT+BLEGAPDEVNAME? # Query current device name
Parameter |
Description |
|---|---|
|
New device name string (1 to 22 characters) |
Requires: Device must be unlocked (AT+SYSUNLOCK first).
Example:
AT+BLEGAPDEVNAME=MySensorTag
Responses:
OK— Device name updated; advertising restarted with the new name+BLEGAPDEVNAME:<name>— Current device name (query)ERROR— Device locked, name too long, or write failure
Note
The default device name is Atmosic Sensor Beacon. Maximum length is set by
CONFIG_BT_DEVICE_NAME_MAX (default: 22 characters).
See BLE Peripheral Commands for full reference.
AT+BLEADVLEGACYPARM
Sets the legacy advertising parameters. Changes take effect immediately.
AT+BLEADVLEGACYPARM=<idx>,<intv_min>,<intv_max>,<duration>
Requires: Device must be unlocked (AT+SYSUNLOCK first).
Examples:
AT+BLEADVLEGACYPARM=0,1600,1600,0 # 1 second interval, indefinite
AT+BLEADVLEGACYPARM=0,400,400,0 # 250 ms interval, indefinite
AT+BLEADVLEGACYPARM=0,3200,3200,0 # 2 second interval, indefinite
Response:
OK— Parameters updated; advertising restartedERROR— Device locked, index invalid, or value out of range
See BLE Peripheral Commands for full reference.
AT+SYSRESET
Resets the device. Warm reset (0) or cold reset (1).
AT+SYSRESET=<type>
Parameter |
Description |
|---|---|
|
|
Requires: Device must be unlocked (AT+SYSUNLOCK first).
Example:
AT+SYSRESET=1
Response: The device resets immediately; no response is returned to the client.
See System Commands for full reference.
Persistent Storage
The following settings survive reboot (saved to NVS flash):
Typical Usage Sequence
# 1. Connect to the device over BLE
# 2. Enable GATT notifications on the TXRX characteristic
# 3. Unlock the device
AT+SYSUNLOCK=atm1atm123 → OK
# 4. Query lock state
AT+SYSLOCK? → +SYSLOCK:OFF
# 5. Change the device name
AT+BLEGAPDEVNAME=MySensorTag → OK
# 6. Set advertising interval to 2 seconds
AT+BLEADVLEGACYPARM=0,3200,3200,0 → OK
# 7. Reset to verify persisted settings
AT+SYSRESET=1 (device resets; reconnect to verify)
Building and Running
This application is built from openair/applications/sensor_beacon.
Production Build (Default)
Optimized for power consumption, performance, and minimal logging:
west build -p always -b <BOARD> openair/applications/sensor_beacon --sysbuild -T applications.sensor_beacon.atm
Production Build with MCUboot + Serial DFU
Enables MCUboot and supports firmware upgrades over UART:
west build -p always -b <BOARD>@mcuboot openair/applications/sensor_beacon --sysbuild -T applications.sensor_beacon.atm.mcuboot.dfu
Debug Build
Enhanced logging and debugging aids for development:
west build -p always -b <BOARD> openair/applications/sensor_beacon --sysbuild -T applications.sensor_beacon.atm -DFILE_SUFFIX=debug
Example for ATMEVK-3430e-YQN-5:
Production:
west build -p always -b ATMEVK-3430e-YQN-5 openair/applications/sensor_beacon --sysbuild -T applications.sensor_beacon.atm
Debug:
west build -p always -b ATMEVK-3430e-YQN-5 openair/applications/sensor_beacon --sysbuild -T applications.sensor_beacon.atm -DFILE_SUFFIX=debug
Programming
To flash the built images:
west flash --no-rebuild -d build --verify --device <DEVICE_ID> --jlink --fast_load
Example:
west flash --no-rebuild -d build --verify --device 000900066361 --jlink --fast_load
Configuration Differences
The debug and production builds have identical functionality - they differ only in logging verbosity:
Feature |
Production Build |
Debug Build |
|---|---|---|
Logging Level |
Warning/Error only (level 2) |
Debug/Verbose (level 4) |
ADC Logging |
Error level only |
Debug level |
Sensor Logging |
Warning level only |
Debug level |
Function Names |
Not logged |
Logged with debug messages |
All Other Settings |
Identical |
Identical |
Note
Both configurations maintain the same:
Update intervals (1 second)
Beacon advertising intervals (1-1.2s normal, 100-150ms fast)
Power management settings
Stack sizes
Watchdog configuration
BLE advertising behavior (dual advertising sets)
Sensor functionality
Testing
To build and run the test suite:
west build -p always -b <BOARD> openair/applications/sensor_beacon/tests --sysbuild
west flash --no-rebuild -d build --verify --device <DEVICE_ID> --jlink --fast_load
Example:
west build -p always -b ATMEVK-3430e-YQN-5 openair/applications/sensor_beacon/tests --sysbuild
west flash --no-rebuild -d build --verify --device 000900066361 --jlink --fast_load
The test suite includes:
Sensor interface validation
Battery monitoring tests
Beacon advertising tests (dual advertising sets, device name updates)
AT command interface tests (lock/unlock, device name, reset)
Data collection and sensor integration tests
Power Management
The application supports Zephyr power management:
Periodic sensor readings with configurable intervals
Automatic sleep between operations
Watchdog integration for reliability
Supported Boards
The sensor_beacon application has been tested and verified on the following platforms:
ATM34 Platforms
ATMBTCSTAG-3405 - ATM34 Tag Reference Design
Button power control enabled by default
Dual LED support
Sensors: ENS210 (Temp/Humidity), LIS3DH (Accelerometer)
Optimized for battery-powered operation with SoC_off support
ATMEVK-3430e-YQN-5 - ATM34 Evaluation Kit
ATMEVK-3405-PBV-5 - ATM34 Evaluation Kit
ATMEVK-3405-PQK-5 - ATM34 Evaluation Kit
ATMEVK-3405-WQK-5 - ATM34 Evaluation Kit
ATMEVK-3405-YBV-5 - ATM34 Evaluation Kit
Immediate beaconing mode (no button power control)
LED support for beacon status indication
Sensors: ENS210 (Temp/Humidity), LIS2DH12 (Accelerometer)
Suitable for development and testing
ATM33 Platforms
ATMEVK-3330e-QN-6 - ATM33 Evaluation Kit (Planned)
ATMEVK-3330e-QN-7 - ATM33 Evaluation Kit (Planned)
Immediate beaconing mode (no button power control)
LED support for beacon status indication
Sensors: ENS210 (Temp/Humidity), LIS2DH12 (Accelerometer)
Suitable for development and testing
All supported platforms use the same sensor set for consistent data collection across different hardware configurations.
Compatibility
Data Format: Uses standardized sensor beacon data format
Advertisement Structure: Standard Bluetooth beacon format with manufacturer data
Passive Observers: Compatible with any BLE scanner or beacon monitoring application (Atmosic DevTools, etc.) — no connection required to receive sensor data
BLE Centrals: Can connect to the device, authenticate via
AT+SYSUNLOCK, and issue configuration commands over the GATT TXRX characteristic
Dependencies
Required Hardware:
ENS210 temperature/humidity sensor
LIS2DH accelerometer
Ensure that the appropriate jumper (JP25) is installed to enable the sensor subsystem. Refer to the EVK’s user guide for additional details.