For my final project in the Medical Devices Lab course, I built a working EKG Device using 2 Arduino Feathers - one battery powered connected to the patient and the other connected to a computer to display the results (Bluetooth connected for Electrical Isolation).
This peripheral device inputs EKG signals through an audio port at an amplitude of 1 to 2mVpp. This signal is then amplified and filtered before being sent over Bluetooth to the central device. The central device, using CircuitPython graphs the incoming data stream and calculates the BPM.
Here's a demo of the live updating.
I designed the PCB in Altium to be as small as possible. The components are very tight together and use all the space available on the board. Because this is essentially a shield for the Feather, I had to make sure that the components wouldn't hit the Feather's components.
I designed the full schematic in Altium. The signal passes through a differential amplifier, a low-pass filter, and then another a amplifier, and then a high-pass filter before the final amplifier. The total amplification is 61dB (1122x).
Most modern EKGs use 10 electrodes, however the simplest EKG can be produced with 3 leads - Right Arm, Left Arm, and Left Leg. Unfortunately, movement can make the signal very messy and noisy, so in the future a median filter should be implemented to allow for the use of this device while exercising.
The way I calculated the heart-rate was through sampling and threshold counting. While this was reliable on the simulator and for many people, every heartbeat is different and especially among people with heartbeat arrhythmias, this way of acquiring the heart rate might not be so effective. Specifically, a high T wave or low R Wave can lead to a miscalculation.
High T = extra peak leads to an overestimate
Low R = missing peak leads to an underestimate
To mitigate this, I averaged many heart-rate calculations to find a better estimate, and while doing live calculations I could remove outliers and give a good live reading.