DIY ECG Heart Monitor | Analog Interface + Arduino
by mcmchris in Circuits > Sensors
3292 Views, 2 Favorites, 0 Comments
DIY ECG Heart Monitor | Analog Interface + Arduino
Hello to everyone, today I am here to show you a very insteresting project that I was working on for a while, it consists on a DIY Electrocardiograph (ECG) that extracts data directly from your heart electrical impulses with some electrodes (from your preferred lead) and a reference right leg driver. It uses several stages to filter the heart signal:
- Instrumentation amplifier.
- High Pass Filter (@0.1Hz)
- Low Pass Filter (@160Hz)
- Notch Filter (@60Hz)
- Level Shifter (offset: 1.6v dc)
I am using the ESP32 to process the signal, the code spend a while analysing the signal to find the largest peak to make the noise of life 😂, then calculates the time between 10 pulses to average the BPM (the code could be modified to perform better).
Here I leave you a tutorial with all the information so you can make your own version.If you are a visual learner I know that a video worth more than 1000 words, so here is a Tutorial video. (I am a Spanish speaker, so please consider turning on English subtitles):
Skills Required
This project may seem difficult or very complex, but it is definitely not completely, since you will have all the guidance for the construction, it was difficult for me to design it to make life a little easier for you. Any conceptual doubt, you are free to ask it without problems.
You should have understandings on:
- Analog electronics.
- Arduino programming
- Circuit making.
- PCB design (optional)
The PCB design attached in the project is SMD, nevertheless, you can make your equivalent version using the diagram in TH devices.
Components and Parts List
The Electronics discrete components as resistors and transistors will be attached in a BOM file attached here.
🛒Materials:
Circuit Diagram and Schematic
Here is the Circuit Diagram of our project:
It has all the internal conections of the circuit that will us allow to create the PCB design later.
I also attached the PDF of the Schematics so you can see it better.
Downloads
PCB Design and Ordering
For the implementation of a good project we need a reliable assembly for the circuit that makes it up, and there is no better way to do it than with a good PCB.
I suggest JLCPCB:
Assambling the Whole Project
In my first attempt of the project I missed the Right Leg Driver stage in the circuit, because of that I got obligated to assamble it on a protoboard, nevertheless, the files an diagrams attached in the project are already corrected and fixed, also the PCB has the missing components and parts.
Because of that, you may ignore the mess of jumping wires and audio jacks.
- You just need to power up the circuit with +5V and GND.
- Connect an active buzzer to a digital output pin of your microcontroller.
- Connect the signal output of the circuit to an analog input of the microcontroller.
And let's jump to the code.
Connect the Electrodes
There are many leads where you can connect the electrodes but I show you the lead I did.
As nearest you place the electrodes to your heart, you will have a greater amplitude output signal.
If you don't want to place them in your chest, you can do it in your arms directly. (Play with different positions to find the best).
Electrodes are really sticky and the adhesive can dry your skin, nothing lethal 😉.
Code and Programming the ESP32 Microcontroller
Download the CODE here for FREE (just insert 0 in the charge box).
After you have opened the code in your Arduino IDE verify:
- Select your board, in my case the Feather ESP32.
- Connect the board by USB to your PC.
- Select the Port that appears on your IDE.
- Verify your code compiles.
- Upload the code.
A little explanation:
The code let the microcontroller to scan the input ECG signal and find the lowest peak and it's value (typical the R part of the ECG signal), then based on this ADC value, ask repetitively if the ADC sees a peak like the one learned before, then make a sound and average 10 pulses to return the BPM in the serial monitor.
Testing and Verifying That You Are Alive
Once you have placed your electrodes, turn on the system by connecting the USB cable to your board and let it scan the signal, then your buzzer should start sounding.
If you have an oscilloscope, please verify the integrity of the signal, if it presents a lot of noise try adjusting the notch filter frequency and the gain.
Reset the microcontroller so it can learns the new and corrected signal. Enjoy the project, you can attach an LCD to print the BPM and a matrix screen to plot the ECG graph.
PD: To get a cleaner and nice signal don't be barefoot, do not touch walls of your house and a nice trick is to touch a gnd cable of your circuit and it gets even better (this is the right leg driver job but just tested and works).