7.7.16. PIR Detection
Edge AI solution for PIR sensor-based motion classification on the MSPM0G5187 with NPU acceleration.
7.7.16.1. Overview
This example demonstrates an Edge AI solution for classifying Passive Infrared (PIR) sensor signals into motion categories. By leveraging machine learning on the MSPM0G5187 with its integrated NPU, the system can distinguish between different types of motion, significantly reducing false positives caused by pets and environmental factors.
Application: Security systems, smart home automation, occupancy sensing
Task Type: Time Series Classification
Data Type: Multivariate (PIR sensor signals)
7.7.16.2. Device Support
The primary target device is the MSPM0G5187. The following devices are also fully supported:
Device |
Description |
Configuration File |
|---|---|---|
|
MSPM0 with NPU (primary) |
|
|
Wireless MCU |
|
|
Multi-protocol wireless MCU |
|
|
Sub-GHz + BLE MCU |
|
|
Wi-Fi MCU |
|
Check the config_<device>.yaml files for device-specific configurations.
7.7.16.3. System Components
Hardware
MSPM0G5187 with integrated NPU
EdgeAI Sensor Boosterpack (TIDA-010997) with PIR sensor
Software
Code Composer Studio (CCS) 12.x or later
MSPM0 SDK 2.08.00 or later (MSPM0-SDK)
TI Edge AI Studio
7.7.16.4. Running the Example
cd tinyml-modelzoo
# Run with MSPM0 configuration (primary)
./run_tinyml_modelzoo.sh examples/pir_detection/config_MSPM0.yaml
# Run with other device configurations
./run_tinyml_modelzoo.sh examples/pir_detection/config.yaml
./run_tinyml_modelzoo.sh examples/pir_detection/config_CC1352.yaml
./run_tinyml_modelzoo.sh examples/pir_detection/config_CC1354.yaml
./run_tinyml_modelzoo.sh examples/pir_detection/config_CC35X1.yaml
cd tinyml-modelzoo
# Run with MSPM0 configuration (primary)
.\run_tinyml_modelzoo.bat examples\pir_detection\config_MSPM0.yaml
# Run with other device configurations
.\run_tinyml_modelzoo.bat examples\pir_detection\config.yaml
.\run_tinyml_modelzoo.bat examples\pir_detection\config_CC1352.yaml
.\run_tinyml_modelzoo.bat examples\pir_detection\config_CC1354.yaml
.\run_tinyml_modelzoo.bat examples\pir_detection\config_CC35X1.yaml
7.7.16.5. Dataset Description
The pir_detection_classification dataset contains PIR sensor data captured
using the EdgeAI Sensor Boosterpack from a range of 6-8 meters.
Download: pir_detection_classification_dsk.zip
Classes (3):
Class |
Description |
|---|---|
Human Motion |
Motion patterns produced by humans |
Background Motion |
Environmental and non-living motion sources |
Dog Motion |
Motion patterns produced by dogs |
7.7.16.6. Feature Extraction Pipeline
The feature extraction pipeline processes raw PIR sensor data through the following stages:
ADC Sampling – Raw sensor data acquisition
DC Offset Removal – Removes baseline drift from the signal
Windowed Processing – Segments the signal into analysis windows
Symmetric Mirroring – Prepares the signal for FFT computation
FFT Computation – Transforms signal to frequency domain
Magnitude Calculation – Computes spectral magnitudes
Average Pooling – Reduces dimensionality of frequency features
Additional Features – Extracts supplementary features:
Zero Crossing Rate (ZCR)
Slope Changes
Dominant Frequency
Feature Concatenation – Combines all features into the final input vector
7.7.16.7. Model
Model |
Parameters |
Description |
|---|---|---|
|
~53K+ |
Compact CNN, NPU compatible, optimized for multivariate input signals |
7.7.16.8. Expected Results
Configuration |
Accuracy |
|---|---|
CC1352 with floating point feature extraction |
~98% |
MSPM0 with fixed point feature extraction |
~92.46% |
7.7.16.9. Training Configuration
The default training hyperparameters are:
batch_size: 64
lr: 0.00001
optimizer: Adam
weight_decay: 1e-20
epochs: 100
Quantization: INT8 quantization is applied for NPU compatibility on the MSPM0G5187.
Compilation: The TI Neural Network Compiler (TI NNC)
generates the compiled artifacts model.a and tvmgen_default.h for
on-device deployment.