LogoLogo
HomeDocsAPI & SDKsProjectsForumStudio
  • Welcome
    • Featured Machine Learning Projects
      • Getting Started with the Edge Impulse Nvidia TAO Pipeline - Renesas EK-RA8D1
      • Smart City Traffic Analysis - NVIDIA TAO + Jetson Orin Nano
      • ROS 2 Pick and Place System - Arduino Braccio++ Robotic Arm and Luxonis OAK-D
      • Optimize a cloud-based Visual Anomaly Detection Model for Edge Deployments
      • Rooftop Ice Detection with Things Network Visualization - Nvidia Omniverse Replicator
      • Surgery Inventory Object Detection - Synthetic Data - Nvidia Omniverse Replicator
      • NVIDIA Omniverse - Synthetic Data Generation For Edge Impulse Projects
      • Community Guide – Using Edge Impulse with Nvidia DeepStream
      • Computer Vision Object Counting - Avnet RZBoard V2L
      • Gesture Appliances Control with Pose Detection - BrainChip AKD1000
      • Counting for Inspection and Quality Control - Nvidia Jetson Nano (TensorRT)
      • High-resolution, High-speed Object Counting - Nvidia Jetson Nano (TensorRT)
    • Prototype and Concept Projects
      • Renesas CK-RA6M5 Cloud Kit - Getting Started with Machine Learning
      • TI CC1352P Launchpad - Getting Started with Machine Learning
      • OpenMV Cam RT1062 - Getting Started with Machine Learning
      • Getting Started with Edge Impulse Experiments
  • Computer Vision Projects
    • Workplace Organizer - Nvidia Jetson Nano
    • Recyclable Materials Sorter - Nvidia Jetson Nano
    • Analog Meter Reading - Arduino Nicla Vision
    • Creating Synthetic Data with Nvidia Omniverse Replicator
    • SonicSight AR - Sound Classification with Feedback on an Augmented Reality Display
    • Traffic Monitoring - Brainchip Akida
    • Multi-camera Video Stream Inference - Brainchip Akida
    • Industrial Inspection Line - Brainchip Akida
    • X-Ray Classification and Analysis - Brainchip Akida
    • Inventory Stock Tracker - FOMO - BrainChip Akida
    • Container Counting - Arduino Nicla Vision
    • Smart Smoke Alarm - Arduino Nano 33
    • Shield Bot Autonomous Security Robot
    • Cyclist Blind Spot Detection - Himax WE-I Plus
    • IV Drip Fluid-Level Monitoring - Arduino Portenta H7
    • Worker PPE Safety Monitoring - Nvidia Jetson Nano
    • Delivered Package Detection - ESP-EYE
    • Bean Leaf Disease Classification - Sony Spresense
    • Oil Tank Measurement Using Computer Vision - Sony Spresense
    • Object Counting for Smart Industries - Raspberry Pi
    • Smart Cashier with FOMO - Raspberry Pi
    • PCB Defect Detection with Computer Vision - Raspberry Pi
    • Bicycle Counting - Sony Spresense
    • Counting Eggs with Computer Vision - OpenMV Cam H7
    • Elevator Passenger Counting - Arduino Nicla Vision
    • ESD Protection using Computer Vision - Seeed ReComputer
    • Solar Panel Defect Detection - Arduino Portenta H7
    • Label Defect Detection - Raspberry Pi
    • Dials and Knob Monitoring with Computer Vision - Raspberry Pi
    • Digital Character Recognition on Electric Meter System - OpenMV Cam H7
    • Corrosion Detection with Computer Vision - Seeed reTerminal
    • Inventory Management with Computer Vision - Raspberry Pi
    • Monitoring Retail Checkout Lines with Computer Vision - Renesas RZ/V2L
    • Counting Retail Inventory with Computer Vision - Renesas RZ/V2L
    • Pose Detection - Renesas RZ/V2L
    • Product Quality Inspection - Renesas RZ/V2L
    • Smart Grocery Cart Using Computer Vision - OpenMV Cam H7
    • Driver Drowsiness Detection With FOMO - Arduino Nicla Vision
    • Gastroscopic Image Processing - OpenMV Cam H7
    • Pharmaceutical Pill Quality Control and Defect Detection
    • Deter Shoplifting with Computer Vision - Texas Instruments TDA4VM
    • Smart Factory Prototype - Texas Instruments TDA4VM
    • Correct Posture Detection and Enforcement - Texas Instruments TDA4VM
    • Visual Anomaly Detection with FOMO-AD - Texas Instruments TDA4VM
    • Surface Crack Detection and Localization - Texas Instruments TDA4VM
    • Surface Crack Detection - Seeed reTerminal
    • Retail Image Classification - Nvidia Jetson Nano
    • SiLabs xG24 Plus Arducam - Sorting Objects with Computer Vision and Robotics - Part 1
    • SiLabs xG24 Plus Arducam - Sorting Objects with Computer Vision and Robotics - Part 2
    • Object Detection and Visualization - Seeed Grove Vision AI Module
    • Bike Rearview Radar - Raspberry Pi
    • Build a Self-Driving RC Vehicle - Arduino Portenta H7 and Computer Vision
    • "Bring Your Own Model" Image Classifier for Wound Identification
    • Acute Lymphoblastic Leukemia Classifier - Nvidia Jetson Nano
    • Hardhat Detection in Industrial Settings - Alif Ensemble E7
    • Motorcycle Helmet Identification and Traffic Light Control - Texas Instruments AM62A
    • Import a Pretrained Model with "Bring Your Own Model" - Texas Instruments AM62A
    • Product Inspection with Visual Anomaly Detection - FOMO-AD - Sony Spresense
    • Visual Anomaly Detection in Fabric using FOMO-AD - Raspberry Pi 5
    • Car Detection and Tracking System for Toll Plazas - Raspberry Pi AI Kit
    • Visual Anomaly Detection - Seeed Grove Vision AI Module V2
    • Object Counting with FOMO - OpenMV Cam RT1062
    • Visitor Heatmap with FOMO Object Detection - Jetson Orin Nano
    • Vehicle Security Camera - Arduino Portenta H7
  • Audio Projects
    • Occupancy Sensing - SiLabs xG24
    • Smart Appliance Control Using Voice Commands - Nordic Thingy:53
    • Glass Window Break Detection - Nordic Thingy:53
    • Illegal Logging Detection - Nordic Thingy:53
    • Illegal Logging Detection - Syntiant TinyML
    • Wearable Cough Sensor and Monitoring - Arduino Nano 33 BLE Sense
    • Collect Data for Keyword Spotting - Raspberry Pi Pico
    • Voice-Activated LED Strip - Raspberry Pi Pico
    • Snoring Detection on a Smart Phone
    • Gunshot Audio Classification - Arduino Nano 33 + Portenta H7
    • AI-Powered Patient Assistance - Arduino Nano 33 BLE Sense
    • Acoustic Pipe Leakage Detection - Arduino Portenta H7
    • Location Identification using Sound - Syntiant TinyML
    • Environmental Noise Classification - Nordic Thingy:53
    • Running Faucet Detection - Seeed XIAO Sense + Blues Cellular
    • Vandalism Detection via Audio Classification - Arduino Nano 33 BLE Sense
    • Predictive Maintenance Using Audio Classification - Arduino Nano 33 BLE Sense
    • Porting an Audio Project from the SiLabs Thunderboard Sense 2 to xG24
    • Environmental Audio Monitoring Wearable - Syntiant TinyML - Part 1
    • Environmental Audio Monitoring Wearable - Syntiant TinyML - Part 2
    • Keyword Spotting - Nordic Thingy:53
    • Detecting Worker Accidents with Audio Classification - Syntiant TinyML
    • Snoring Detection with Syntiant NDP120 Neural Decision Processor - Arduino Nicla Voice
    • Recognize Voice Commands with the Particle Photon 2
    • Voice Controlled Power Plug with Syntiant NDP120 (Nicla Voice)
    • Determining Compressor State with Audio Classification - Avnet RaSynBoard
    • Developing a Voice-Activated Product with Edge Impulse's Synthetic Data Pipeline
    • Enhancing Worker Safety using Synthetic Audio to Create a Dog Bark Classifier
  • Predictive Maintenance and Defect Detection Projects
    • Predictive Maintenance - Nordic Thingy:91
    • Brushless DC Motor Anomaly Detection
    • Industrial Compressor Predictive Maintenance - Nordic Thingy:53
    • Anticipate Power Outages with Machine Learning - Arduino Nano 33 BLE Sense
    • Faulty Lithium-Ion Cell Identification in Battery Packs - Seeed Wio Terminal
    • Weight Scale Predictive Maintenance - Arduino Nano 33 BLE Sense
    • Fluid Leak Detection With a Flowmeter and AI - Seeed Wio Terminal
    • Pipeline Clog Detection with a Flowmeter and AI - Seeed Wio Terminal
    • Refrigerator Predictive Maintenance - Arduino Nano 33 BLE Sense
    • Motor Pump Predictive Maintenance - Infineon PSoC 6 WiFi-BT Pioneer Kit + CN0549
    • BrickML Demo Project - 3D Printer Anomaly Detection
    • Condition Monitoring - Syntiant TinyML Board
    • Predictive Maintenance - Commercial Printer - Sony Spresense + CommonSense
    • Vibration Classification with BrainChip's Akida
    • AI-driven Audio and Thermal HVAC Monitoring - SeeedStudio XIAO ESP32
  • Accelerometer and Activity Projects
    • Arduino x K-Way - Outdoor Activity Tracker
    • Arduino x K-Way - Gesture Recognition for Hiking
    • Arduino x K-Way - TinyML Fall Detection
    • Posture Detection for Worker Safety - SiLabs Thunderboard Sense 2
    • Hand Gesture Recognition - OpenMV Cam H7
    • Arduin-Row, a TinyML Rowing Machine Coach - Arduino Nicla Sense ME
    • Fall Detection using a Transformer Model – Arduino Giga R1 WiFi
    • Bluetooth Fall Detection - Arduino Nano 33 BLE Sense
    • Monitor Packages During Transit with AI - Arduino Nano 33 BLE Sense
    • Smart Baby Swing - Arduino Portenta H7
    • Warehouse Shipment Monitoring - SiLabs Thunderboard Sense 2
    • Gesture Recognition - Bangle.js Smartwatch
    • Gesture Recognition for Patient Communication - SiLabs Thunderboard Sense 2
    • Hospital Bed Occupancy Detection - Arduino Nano 33 BLE Sense
    • Porting a Posture Detection Project from the SiLabs Thunderboard Sense 2 to xG24
    • Porting a Gesture Recognition Project from the SiLabs Thunderboard Sense 2 to xG24
    • Continuous Gait Monitor (Anomaly Detection) - Nordic Thingy:53
    • Classifying Exercise Activities on a BangleJS Smartwatch
  • Air Quality and Environmental Projects
    • Arduino x K-Way - Environmental Asthma Risk Assessment
    • Gas Detection in the Oil and Gas Industry - Nordic Thingy:91
    • Smart HVAC System with a Sony Spresense
    • Smart HVAC System with an Arduino Nicla Vision
    • Indoor CO2 Level Estimation - Arduino Portenta H7
    • Harmful Gases Detection - Arduino Nano 33 BLE Sense
    • Fire Detection Using Sensor Fusion and TinyML - Arduino Nano 33 BLE Sense
    • AI-Assisted Monitoring of Dairy Manufacturing Conditions - Seeed XIAO ESP32C3
    • AI-Assisted Air Quality Monitoring - DFRobot Firebeetle ESP32
    • Air Quality Monitoring with Sipeed Longan Nano - RISC-V Gigadevice
    • Methane Monitoring in Mines - Silabs xG24 Dev Kit
    • Smart Building Ventilation with Environmental Sensor Fusion
    • Sensor Data Fusion with Spresense and CommonSense
    • Water Pollution Detection - Arduino Nano ESP32 + Ultrasonic Scan
    • Fire Detection Using Sensor Fusion - Arduino Nano 33 BLE Sense
  • Novel Sensor Projects
    • 8x8 ToF Gesture Classification - Arduino RP2040 Connect
    • Food Irradiation Dose Detection - DFRobot Beetle ESP32C3
    • Applying EEG Data to Machine Learning, Part 1
    • Applying EEG Data to Machine Learning, Part 2
    • Applying EEG Data to Machine Learning, Part 3
    • Liquid Classification with TinyML - Seeed Wio Terminal + TDS Sensor
    • AI-Assisted Pipeline Diagnostics and Inspection with mmWave Radar
    • Soil Quality Detection Using AI and LoRaWAN - Seeed Sensecap A1101
    • Smart Diaper Prototype - Arduino Nicla Sense ME
    • DIY Smart Glove with Flex Sensors
    • EdgeML Energy Monitoring - Particle Photon 2
    • Wearable for Monitoring Worker Stress using HR/HRV DSP Block - Arduino Portenta
  • Software Integration Demos
    • Azure Machine Learning with Kubernetes Compute and Edge Impulse
    • ROS2 + Edge Impulse, Part 1: Pub/Sub Node in Python
    • ROS2 + Edge Impulse, Part 2: MicroROS
    • Using Hugging Face Datasets in Edge Impulse
    • Using Hugging Face Image Classification Datasets with Edge Impulse
    • Edge Impulse API Usage Sample Application - Jetson Nano Trainer
    • MLOps with Edge Impulse and Azure IoT Edge
    • A Federated Approach to Train and Deploy Machine Learning Models
    • DIY Model Weight Update for Continuous AI Deployments
    • Automate the CI/CD Pipeline of your Models with Edge Impulse and GitHub Actions
    • Deploying Edge Impulse Models on ZEDEDA Cloud Devices
Powered by GitBook
On this page
  • Introduction
  • Requirements
  • Circuit
  • ECG Intervals
  • Data Acquisition
  • The HR-HRV Block
  • Model Training
  • Deployment
  • Final Notes
  • Files and Project Link
  • References

Was this helpful?

Edit on GitHub
Export as PDF
  1. Novel Sensor Projects

Wearable for Monitoring Worker Stress using HR/HRV DSP Block - Arduino Portenta

Use an Arduino Portenta and ECG sensors to monitor stress levels with the Edge Impulse HR/HRV machine learning algorithm.

PreviousEdgeML Energy Monitoring - Particle Photon 2NextSoftware Integration Demos

Last updated 4 months ago

Was this helpful?

Created By: Roni Bandini

Public Project Link:

GitHub Repo:

Introduction

During the Apollo missions astronauts wore ECG sensors to monitor their stress levels and assess their ability to perform complex tasks. These ECG signals were manually monitored from Earth, over a distance of 238,855 miles away, making the process challenging due to delays and data transmission errors. Today, advancements in technology have led to the development of small, inexpensive, offline wearable devices that utilize machine learning to determine stress levels. These modern devices can alert when a worker is unable to perform a critical task, ensuring safety and efficiency without the need for remote monitoring.

How complicated is it to obtain ECG data, extract specific features with the Edge Impulse HR/HRV Processing Block, train a model, and deploy the model to create an Arduino wearable? Let's investigate and find out!

Disclaimer: This project is experimental and it is not intended to diagnose or treat any medical conditions.

Requirements

1 x Arduino Portenta H7 1 x AD8232 SparkFun Single Lead Heart Rate Monitor 5 x female-female jumper cables Edge Impulse Account

Note: All Edge Impulse users (Community, Professional, and Enterprise) can extract heart rate and HRV features using this block for testing purposes. However, the Deployment option is only available for Enterprise users.

Circuit

Connect AD8232 Output to A0 Connect AD8232 Lo – to D2 Connect AD8232 Lo + to D3

Lo means "Leads off" detection. The AD8232 also includes a shutdown pin (SDN) that is not used for this case. A logic level signal can be applied to SDN to switch to shutdown mode, even when the supply is still on.

Connect the pads jack right all way to the end, disconnect the AC from the laptop and move away all radio devices before sampling. Use good quality, new pads for each measurement.

ECG Intervals

The ECG is separated into two basic intervals: the PR Interval and the QT Interval. The PR interval is the initial wave generated by an electrical impulse traveling from the right atrium to the left. Then inside the QT there is a complex process that generates the signature "beep" in cardiac monitors. During QRS both ventricles begin to pump. After the initial contraction comes the ST segment (the time where the ventricals waiting to be "re-polarized"). Finally the T wave becomes present to actively "re-ploarize", or relax the ventricles.

Data Acquisition

For this project, the data will be the electrical activity of the heart. The AD8232 sensor is designed to extract, amplify, and filter small biopotential signals in the presence of noisy conditions, such as those created by motion or remote electrode placement.

The ECG signal can also be combined with data from an accelerometer for enhanced diagnostics. Some Arduino boards, like the Arduino BLE 33 Sense, have an onboard accelerometer, so with a small code modification, that data can also be used to train the model.

The pads should be connected as follow:

  • Yellow pad to the left.

  • Red pad to the right.

  • Green pad below the red pad.

Note: Remember to disconnect the AC from the laptop before sampling.

Upload the Data Forwarding acquisition script to the Arduino Portenta using the Arduino IDE.

Check that the values being obtained are stable in the Serial Monitor (Center value of about ~500 with spikes between +300/-200)

Note: Even with all these precautions, the AD8232 module could still produce a noisy signal. For a real deployment it is recommended to use professional equipment like the Elemyo EMG/ECG module MYO v1.5. For this Public Project synthetic data was used.

Close the Serial Monitor and run edge-impulse-data-forwarder.

Select the Edge Impulse project and check that the frequency shows [SER] Detected data frequency: 50Hz.

Select Length 120.000 ms and take around 10 to 20 samples for each category to classify. For example, regular working versus stressed. Set aside 10% of the samples for testing.

The HR-HRV Block

Edge Impulse recently added a learning block specifically designed for this scenario.

The HR/HRV Features block processes physiological signals like the electrocardiogram (ECG), with optional accelerometer inputs for enhanced accuracy in motion-prone applications, to extract key metrics such as heart rate (HR) and heart rate variability (HRV). HR measures the number of beats per minute, while HRV measures the time variance between successive heartbeats, also known as the interbeat interval (IBI). The block offers real-time HR estimation and HRV analysis on resource-constrained edge devices and leverages cutting-edge algorithms for precise feature extraction. The extracted features can be used on their own or to inform downstream machine learning tasks such as stress detection or heart health analysis.

For this project, stress detection is performed with a classification algorithm, as the model has already been trained with ECG data from both regular working conditions and stressed conditions. However, if you extract all the HRV features, you can also determine stress by analyzing frequency domain features such as Raw VLF Energy, Raw LF Energy, Raw HF Energy, Relative VLF Energy, and the LF/HF Ratio Peak Energy. Just note that you will need a window size of 90 seconds (10 seconds for RMSSD and 30 seconds for time domain analysis).

Time-domain features are: IBI Slope, HR Mean, HR Slope, RMSSD Slope, RMSSD, AVNN, SDNN, Range NN, MAD NN and pNN50.

Frequency-domain features are: Raw VLF Energy, Raw LF Energy, Raw HF Energy, Raw Total Energy, Relative VLF Energy, Relative LF Energy, Relative HF Energy, LF/HF Ratio, Peak VLF Energy, Peak LF Energy, Peak HF Energy

I have used ECG, filter preset 1, window size 40 and no HRV features.

Model Training

The training could require some parameters to be modified from the defaults. I have found the following parameters to work well for my dataset, with a 89.3% accuracy. Training cycles 40, learning rate 0.005, bacth size 30 and no auto weight.

Deployment

For projects using the Edge Impulse HRV DSP block, a license to deploy is required, so there is a button to authorize this feature.

After the authorization you will be able to get the model as an Arduino library. However, an intermediate step is required.

  1. Unzip the deployment file into a local folder on your laptop.

  2. Unzip the files and copy them to the local folder you created in Step 1.

  3. Zip the folder, now with the additional files included, back into a single archive / .zip file

  4. Add the new .zip file as a library in the Arduino IDE (Skectch, Include Library, Add Zip library)

Note: If Arduino Portenta shows Exit status 74, double click "Reset", and select the correct port.

Final Notes

Thanks to machine learning, monitoring ECG signals no longer requires transmitting data to a remote computer for expert analysis. Instead, subtle health conditions can be detected by small, offline, wearable devices equipped with machine learning capabilities. These devices can identify over-stressed workers who may be unable to perform their tasks effectively, thus preventing serious harm or consequences.

Files and Project Link

References

Go to

Download a zip containing all files from .

Now you will be able to use the model library with your own code. A sample ECG monitor script using the compiled .zip file can be found at

https://studio.edgeimpulse.com/studio/Your-Project-ID/acquisition/training
https://github.com/edgeimpulse/example-hr-lib-arm
https://github.com/ronibandini/hr-hrv/blob/main/ecg2.ino
https://studio.edgeimpulse.com/studio/558080
https://github.com/ronibandini/hr-hrv/
https://docs.edgeimpulse.com/docs/edge-impulse-studio/processing-blocks/hr-hrv-block
https://docs.edgeimpulse.com/docs/edge-ai-hardware/mcu/arduino-portenta-h7
https://www.edgeimpulse.com/blog/unraveling-the-depths-of-hr-and-hrv-edge-impulses-technical-insights/
https://learn.sparkfun.com/tutorials/ad8232-heart-rate-monitor-hookup-guide
https://pmc.ncbi.nlm.nih.gov/articles/PMC10098909/
https://www.theatlantic.com/science/archive/2019/07/apollo-11-moon-heart-rates/593971/
https://elemyo.com/support/start_info/myo_v1_4
https://studio.edgeimpulse.com/studio/558080
https://github.com/ronibandini/hr-hrv