This project contains code for an ECG peak detection and heart rate calculation algorithm to be used with an Arduino board. The code is written in C++ and consists of the following files:
main.cpp
eventECG.cpp
eventECG.h
debugSettings.h
Makefile
Arduino-ino/Arduino-ino.ino
Arduino-ino/eventECG.cpp
Arduino-ino/Arduino-ino.ino
To compile and run the Windows version of the project, you will need a C++ compiler installed on your computer. The following instructions assume that you are using a Windows system.
- Download the project files and extract them to a folder on your computer.
- Open a command prompt and navigate to the project directory using the following command:
cd path/to/project/folder
- Compile the project using the included Makefile:
make ArduinoECG
If the makefile doesn't work for your system, you can compile the project manually by running the following commands:
g++ -c eventECG.cpp -o eventECG.o
g++ -c main.cpp -o main.o
g++ eventECG.o main.o -o ArduinoECG.exe
- To run the program use .\ArduinoECG.exe \path\to\data\file
- The output will be saved into a file called called output.txt
Input file is a text file with each sample of data is a data row. The input can be a floating point number or an integer. It can be either positive or negative.
The output file is a text file with following three columns
- Sample number (x)
- Peak location (y)
- Calculated, instantanious heart rate (beats per minute)
The Windows version of the ArduinoECG program is designed to read from a file while the Arduino version is taking the input from UART input. There is an example ECG data stream provided in data folder. The sample data consists of three files,
100.txt
- This is the dataset 100 of MIT-BIH database converted into a txt file100-ann.txt
- This is the annotated peaks in samples (x-axis)100-type.txt
- This is the annotation type of each peak. For more information about beat types, please visit database website
Once compiled, use the following command to run with the dataset 100.
.\ArduinoECG.exe .\data\100.txt
To compile and run the Arduino version of the project, you will need an Arduino board and the Arduino IDE installed on your computer. The following instructions assume that you are using a Windows system.
- Download the project files and extract them to a folder on your computer.
- Open the
Arduino-ino.ino
file in the Arduino IDE. - Connect your Arduino board to your computer.
- In the Arduino IDE, select the correct board type and port from the
Tools
menu. - Click the
Upload
button in the Arduino IDE to upload the code to the board. - Run the program and observe the output to verify that the ECG system is functioning as expected.