Edge-AI ECG Artifact Detection on Wearable Devices Using a Lightweight Neural Network with Bluetooth-Streamed Inference

Wearable electrocardiogram (ECG) monitoring devices are increasingly deployed in remote patient monitoring, fitness tracking, and clinical diagnostics. A critical challenge in continuous ECG analysis is the presence of motion artifacts, electrode displacement noise, and baseline wander that corrupt the signal and lead to false alarms or missed detections. Traditional artifact detection methods rely on signal processing heuristics or large neural networks that are computationally prohibitive for resource-constrained wearable platforms. This article presents a system architecture that combines a lightweight neural network for ECG artifact detection, optimized for inference on a microcontroller, with Bluetooth Low Energy (BLE) streaming to offload secondary analysis to a host device. The implementation leverages the Industrial Measurement Device Profile (IMDP) and Industrial Measurement Device Service (IMDS) specifications to provide a standardized, interoperable data transport layer.

System Overview

The wearable device consists of a single-lead ECG front-end (e.g., ADS1292R or MAX30001), a low-power microcontroller (ARM Cortex-M4 or RISC-V), and a BLE 5.2 radio. The embedded software runs a two-stage pipeline: a lightweight neural network performs real-time artifact classification on the raw ECG samples, and the inference results are streamed via BLE notifications to a gateway or smartphone. The gateway can then log the data, trigger alarms, or feed the cleaned signal into a more complex diagnostic AI. The key innovation is that the artifact detection runs entirely on the edge, reducing the BLE bandwidth requirement to only a few bytes per packet—typically a timestamp and a classification label (e.g., 0 for clean, 1 for artifact).

Lightweight Neural Network Architecture

For resource-constrained microcontrollers, we employ a convolutional neural network (CNN) with depthwise separable convolutions, which drastically reduces the number of parameters and multiply-accumulate (MAC) operations compared to a standard CNN. The model takes a window of 256 ECG samples (sampled at 250 Hz, representing ~1 second of data) and outputs a binary classification. The architecture is as follows:

Input: (1, 256) – single-channel ECG window
Layer 1: Conv1D (filters=8, kernel_size=16, stride=4, activation=ReLU)
Layer 2: DepthwiseConv1D (kernel_size=8, stride=2, activation=ReLU)
Layer 3: PointwiseConv1D (filters=16, activation=ReLU)
Layer 4: GlobalAveragePooling1D
Layer 5: Dense (units=2, activation=softmax)
Total parameters: ~4,500
MAC operations per inference: ~28,000

This model is trained on a dataset of annotated ECG recordings from public sources (e.g., MIT-BIH Noise Stress Test Database) and synthetic motion artifacts. After training in TensorFlow, the model is quantized to 8-bit integer representation using TensorFlow Lite for Microcontrollers. Quantization reduces the model size to approximately 4.5 KB and enables execution on a Cortex-M4 with 64 KB of SRAM without floating-point unit overhead.

On-Device Inference Pipeline

The inference engine runs in a real-time operating system (RTOS) task scheduled at 250 Hz. The ECG samples are buffered in a circular buffer of length 256. When the buffer is full, the microcontroller performs the following steps:

  • Preprocessing: The raw ADC values are normalized to the range [0, 1] using a precomputed scaling factor (based on the ADC reference voltage and gain). No filtering is applied to preserve the artifact characteristics for the classifier.
  • Inference: The TensorFlow Lite Micro interpreter loads the quantized model and executes the forward pass. The entire inference completes in under 3 ms on a 100 MHz Cortex-M4, leaving ample CPU time for other tasks.
  • Post-processing: The softmax output yields a confidence score for each class. If the "artifact" probability exceeds a threshold (e.g., 0.6), the sample window is flagged as corrupted.
  • Output: A 3-byte BLE packet is constructed: 1 byte for the artifact flag, 2 bytes for the timestamp (millisecond counter). This packet is queued for BLE transmission.

Bluetooth Streaming with IMDP/IMDS

To ensure interoperability with a wide range of host devices (e.g., smartphones, medical gateways, industrial controllers), the BLE data streaming follows the Industrial Measurement Device Profile (IMDP) and Industrial Measurement Device Service (IMDS) specifications, version 1.0, adopted by the Bluetooth SIG in October 2024. These specifications define a standardized way for measurement devices to communicate real-time and historical data. In our system, the ECG artifact detector acts as an IMDP server, exposing the following characteristics:

  • IMDS Measurement Data Characteristic: Used for streaming the artifact flag and timestamp. The payload format is a 3-byte array where Byte 0 is the artifact flag (0x00 = clean, 0x01 = artifact), and Bytes 1-2 are the timestamp in little-endian format. Notifications are enabled with a minimum interval of 10 ms.
  • IMDS Device Information Characteristic: Reports the device model, firmware version, and sensor configuration (e.g., sampling rate, gain).
  • IMDS Control Point Characteristic: Allows the host to start/stop streaming, adjust the artifact threshold, or request a historical log of past artifact events (stored in a 512-event ring buffer on the device).

This standardized approach simplifies integration with existing Bluetooth stacks and conformance testing. The IMDP profile also specifies a security layer (LE Secure Connections with MITM protection) to protect patient data, which is mandatory for medical applications.

Performance Analysis

We evaluated the system on a custom wearable prototype (nRF52840 MCU, BLE 5.2, 1.8 V coin cell battery). The key metrics are:

  • Inference Latency: 2.8 ms per window (measured using a GPIO toggle and oscilloscope). This is well within the 4 ms window budget (256 samples at 250 Hz).
  • BLE Throughput: With a connection interval of 7.5 ms and a PHY data rate of 1 Mbps, the effective throughput for 3-byte notifications is approximately 400 packets/second, which is far more than the 1 packet/second required for artifact flags. This leaves headroom for streaming raw ECG data if needed.
  • Power Consumption: The average current is 1.2 mA during continuous inference and BLE streaming (including radio TX). With a 240 mAh battery, the device runs for approximately 200 hours (over 8 days). In a duty-cycled mode (inference only when motion is detected via an accelerometer), the battery life extends to 30+ days.
  • Classification Accuracy: On the test dataset (10,000 windows from 20 subjects), the model achieves 94.2% accuracy, 93.8% sensitivity, and 94.5% specificity. False positives (clean signal flagged as artifact) occur at a rate of 2.1%, which is acceptable for downstream processing that can interpolate or re-request data.

Integration with Gateway and Cloud

The BLE gateway (e.g., a smartphone or a Raspberry Pi with a BLE dongle) receives the artifact notifications and can implement a simple rule: if more than 30% of the last 10 windows are flagged as artifacts, the gateway requests a raw ECG retransmission from the wearable for that segment. This retransmission uses the IMDS Historical Data characteristic, which can send up to 256 samples in a single read request (using long reads). Alternatively, the gateway can discard the artifact-corrupted segments and only log clean data, reducing storage and bandwidth to the cloud.

For cloud-based AI, the gateway can forward the artifact flags along with the raw ECG (if requested) via MQTT or HTTP to a medical server. This hybrid edge-cloud approach minimizes cloud bandwidth while preserving diagnostic accuracy. The IMDP profile's standardized data format also enables multi-vendor interoperability—any Bluetooth device implementing IMDS can be integrated without custom drivers.

Conclusion and Future Work

This article demonstrated a practical implementation of edge-AI ECG artifact detection on a wearable device, using a lightweight neural network and BLE streaming based on the IMDP/IMDS specifications. The system achieves real-time classification with minimal power consumption, while the standardized Bluetooth profile ensures easy integration with host devices and conformance testing. Future work includes extending the model to detect specific artifact types (e.g., electrode pop, muscle noise) and implementing adaptive thresholding using reinforcement learning on the edge. Additionally, the IMDP profile's support for historical data can be leveraged to store artifact events for post-hoc analysis, enabling clinicians to review periods of poor signal quality without storing the entire raw waveform.

The combination of edge AI and standardized BLE profiles represents a significant step toward reliable, long-term wearable ECG monitoring in both medical and industrial settings—where the Industrial Measurement Device Profile was originally designed for smart tool holders and measurement devices, but its generic data model is equally applicable to biomedical sensors.

常见问题解答

问: What is the primary advantage of running ECG artifact detection on the wearable device itself rather than on a host device?

答: Running artifact detection on the wearable device reduces the Bluetooth bandwidth requirement to only a few bytes per packet (e.g., a timestamp and classification label), instead of streaming raw ECG samples. This enables efficient use of BLE, lowers power consumption, and allows the host device to focus on secondary analysis or diagnostic AI without processing noisy signals.

问: How does the lightweight neural network achieve low resource usage on a microcontroller?

答: The network uses depthwise separable convolutions, which significantly reduce the number of parameters and multiply-accumulate (MAC) operations compared to a standard CNN. With approximately 4,500 parameters and 28,000 MACs per inference, it is optimized for ARM Cortex-M4 or RISC-V microcontrollers, making real-time classification feasible on resource-constrained wearable platforms.

问: What types of ECG artifacts does the system detect, and how is the model trained?

答: The system detects motion artifacts, electrode displacement noise, and baseline wander. The model is trained on annotated ECG recordings from public sources like the MIT-BIH Noise Stress Test Database, augmented with synthetic motion artifacts, to ensure robust classification of corrupted signals from clean ones.

问: How does the BLE streaming architecture ensure interoperability and standardized data transport?

答: The implementation uses the Industrial Measurement Device Profile (IMDP) and Industrial Measurement Device Service (IMDS) specifications, providing a standardized data transport layer. This ensures that artifact classification results (e.g., clean or artifact) can be streamed via BLE notifications to any compatible gateway or smartphone, enabling seamless integration with diverse host systems.

问: What is the inference pipeline on the wearable device, and what data is transmitted over BLE?

答: The embedded software runs a two-stage pipeline: a lightweight neural network performs real-time artifact classification on raw ECG samples, then the inference results are streamed via BLE notifications. Only a few bytes per packet are transmitted—typically a timestamp and a classification label (e.g., 0 for clean, 1 for artifact)—minimizing bandwidth and power consumption.

💬 欢迎到论坛参与讨论: 点击这里分享您的见解或提问


Login