Arduino ECG/EKG Heart Rate Monitor

The goal of this project is to create a device that can be worn by patient that would monitor the patients heart rate via ECG signals. The arduino would then calculate the patient's heart rate and transmit it wirelessly to a receiver. The receiver would than be connected to a PC which logs the data into a database, issue alerts, display data, etc

This post is basically a log of my current project

Current status: 5%
-ECG Circuit - prototype completed
-Wireless communication - not completed
-Receiver -not completed
-Main program on PC - not completed

Possible additions:
-temperature monitoring

Pls feel free to leave comments, questions, and siggestions

Thanks,
Bigdinotech

ECG Circuit Prototype

I want to see this completed so badly...=D Get to work!

Please post you schematic for the sensor hookup

What instrument Amp are you using?

thanks

Hopefully you are using precautions like 1 Mohm series resistor on all leads going to your skin. If you've got the Arduino plugged in via USB, that ground is connected to your PC ground, which is connected to your wall outlet AC ground. And the electrodes are taped right over your heart so the lethal current threshold to trigger ventricular fibrillation is much lower than normal... accidents can happen! I think commercial EKG equipment always uses optoisolators for complete electrical isolation.

Please post you schematic for the sensor hookup

What instrument Amp are you using?

thanks

I am using a Texas Instruments INA2126PG4 which I purchased from Mouser.
The circuit is pretty much based on the datasheet.
I would post a schematic but I need to find the Eagle file for this part first.

I did a battery-powered heartrate monitor almost 20 years ago, and the completed unit is still on my shelf. Your post inspired me to take a few photos of my lab notebook, and the unit itself. I posted them here:

http://bealecorner.org/best/measure/EKG/

Since it was battery powered and transmitted the output via RF there was no problem with electrical hazards from ground loops, etc. I made my own instrumentation amp from a quad LP324N opamp. It was cheap :-). No doubt there are better options these days.

I was just measuring heartrate so I just did one pulse per beat. To actually record the full EKG waveform you'd have to encode that somehow, probably as a FM tone-encoded signal.

Hopefully you are using precautions like 1 Mohm series resistor on all leads going to your skin. If you've got the Arduino plugged in via USB, that ground is connected to your PC ground, which is connected to your wall outlet AC ground. And the electrodes are taped right over your heart so the lethal current threshold to trigger ventricular fibrillation is much lower than normal... accidents can happen! I think commercial EKG equipment always uses optoisolators for complete electrical isolation.

Thanks for the advice.
I made sure amplifier is battery powered but I forgot about the ground when I connected it to the Arduino. I will keep this in mind the next time I do some tests with this circuit.
The final design for the monitor will however be completely battery powered. Only the receiver will be connected via USB to the PC, which will not have any electrodes.

I did a battery-powered heartrate monitor almost 20 years ago, and the completed unit is still on my shelf. Your post inspired me to take a few photos of my lab notebook, and the unit itself. I posted them here:

Heart Rate Monitor

Since it was battery powered and transmitted the output via RF there was no problem with electrical hazards from ground loops, etc.

I was just measuring heartrate so I just did one pulse per beat. To actually record the full EKG waveform you'd have to encode that somehow, probably as a FM tone-encoded signal.

Thats pretty cool.
Currently, the arduino only calculates the heart rate.
I did this by measuring the time between pulses.
I can use the 10-bit ADC from the arduino to read then send the waveform. but I first need to figure out the wireless communication using the Xbee.
I also want to be able to have more than one device transmitting at the same time.
So I am trying to keeps thing simple for now.
That's why I am trying to minimize the amount of data that would be sent to the receiver.
In the future I do plan to send data on the full waveform but that would really complicate things at the receiver end.

Good luck with your project!

The other thing to remember when testing things, is just about any AC-line powered oscilloscope probe will have the ground lead connected to AC earth ground. Trying to avoid that by using a "ground cheater" plug on the scope power cord is even more dangerous. They drilled that into us in the medical electronics course I took, when they reviewed safety.

Did you see the ECG example with right leg drive
on the INA2128 spec sheet?

I don't see an example with the Right Leg Driver in the DataSheet, But from what I understand, this circuit is for noise filtering purposes.
How many gain stages do you have?

Its on the INA2128 Data sheet from TI

Page 10, Fig 6

Does anyone know the amount of Leakage current that the Arduino Pro Mini can handle before it is damaged, I am not sure which value it corresponds to on the Data Sheet

Hey,

Thanks for the response, but I believe a work-around solution was provided a few posts above (Using 1Mohm Resistors across, the input to the Electrodes) . In any case, if you would happen to know what the value is that I should look out for that would be helpful, because this determines where I can place my bandpass filter.
Thanks

Please do be careful.. one of the many jobs I had over the years was as a "Holter EKG Analyst". A Holter monitor is a 24-hour ECG, at the time they were recorded to audio cassette tape, these days solid state memory is used. The job consisted of doing the sampling from the tape, and then software would pre-process about 90% of the data, processing "normal" beats/rhythm out by binning. That left the remainder to be manually reviewed, whether you were looking at ectopic beats/conduction defects, or simply confirming that the data was bad due to muscular or contact noise. The Holter recorders themselves were battery powered (for portability mainly), but still used optical isolation for safety reasons. Particularly if you are attempting telemetry with people who potentially already have conduction/ectopy defects, applying ANY current to the body is just plain dangerous. Of all the parts of your project, making sure the thing is ironclad safe is the most important thing to spend research time on..

Suffice to say what you are trying to do is very feasible, I did this work nearly fifteen years ago. Even the computers processing the data off the tapes were 486DX's... I'm wondering if the little Arduino may just have the ability to screen (bin out) normal morphology, it's a matter of pattern recognition of a standard QRS complex, those are easy peaks to grab and don't vary a lot in timing unless you get some really funky Junctional ectopy or a full-on Bundle Branch Block. Since that's a damn serious condition, just call 911 if you see it and don't worry about it project-wise. It's important to track P and T outside of the QRS complex, as that's where you will see heart block (PQ interval elongation (I), dissociation (III), and Wenkiebach (II)). ST interval gives you depolarization and refractory time, from which most ventricular conduction problems can be figured out.

At least that's what they taught us back in the day... immensely oversimplified. The point is, the pattern recognition may not be out of the number crunching range of Arduino.. your EKG could autoscreen for many arrhythmias easily just by tracking QRS, morphology is a LOT harder but possibly do-able :wink:

One more thought- you may want to compensate for and detect external pacing. The pacing spike is typically an overdrive of the base atrial pacemaker node rate- overpacing by a BPM or two keeps those nasty little atrial ectopics in refractory while the paced beat does the pump work. The spike itself is what you might need to plan for. If you're using a threshhold to detect QRS, then the pacing spike (being fast and high voltage, comparatively, to a natural atrial self-pacing P) can be misread as a QRS. If this isn't ever seeing clinical or pacing use then you can probably disregard the issue.

Good luck and keep posting!

don't worry too much about the risk of shock from a ground lead that is not isolated. It is really quite hard to electrocute someone. That being said it is pretty easy today to make a fully isolated instrumentation amp. We were doing that 40 years ago and even then it wasn't impossibly hard. It is worthwhile to use ultra low noise op-amps and keep everything running on a few coin cells for absolute safety. The simplest safety system is to use a wireless connection as some of the forum have suggested. If you go to EEG signals then the noise becomes very important as the signals are 1/10 of the ECG ones.

Very interesting. If you add a pulseox if I think you'd be measuring everything that's easily automated.

Is this for fun or are you aiming at a commercial product?

If it's the latter, it's a great idea but you'll hit problems with medical institutions not wanting to dump their GE or WA dinamaps in favour of your device and running them in tandem is a bit pointless.

Is this for fun or are you aiming at a commercial product?

I am doing this project for both fun and educational purposes.

I am also working on a project like this, though I haven't got my Arduino, yet. I'm just using a sound card for now... by merely touching the exposed wires plugged into my sound card with my fingers and intensive filtering in Audacity, I'm able to clearly detect the "R" spike of the QRS complex, and thus a heartbeat... but nothing else is discernible... I'm working on the amplifier.

It occurs to me that it is quite often that a hobbyist is touching things like exposed wires when messing with circuits... and nobody is very worried about it. But once we're actually measuring a heartbeat, it becomes dangerous?

I think there are many parts of this issue with safety and optocoupling/isolation and why it's perceived and/or actually as risky:

  1. Very few accidents have occurred, but because they were caused in hospitals with plenty of people to blame (nurses, doctors, technicians, equipment manufacturers, etc) with lots of money behind them, it becomes a big legal liability problem. Hobbyists typically have no one to blame than themselves, and the rare accident that DOES happen may never be reported or the hobbyist, if they survive, may just brush it off or never even realize the danger they were in versus suing the hospital into the ground for an accident and causing a media sensation, even if the accident causes no (permanent) damage.

  2. Early electrical equipment was overall far less safe than modern equipment... Electrocutions in general were far more common (for those with electricity) because of unsafe grounding practices that are now very rare except in antique equipment. Also, vacuum tubes were used for power supplies, amplifiers, etc. Vacuum tubes, even on amplifier circuits, almost always operate at high, dangerous voltages. Electrical wiring may not have been done by licensed professionals at the time, breakers and fuses were not as commonly placed as they are now, etc.... Thus, the need to be careful with ground was probably greater than it is today, although this sort of attitude can lead to complacency.

  3. Hobbyists are merely ignorant of the danger that they are in. Also, they may use less capable power supplies, often even just batteries.

  4. Medical device manufacturers want to keep the medical device market a very expensive market with little competition, even though the basic specifications of many medical devices could be replicated and exceeded by a hobbyist (and thus probably easily mass-produced) for very little money... Medical device manufacturers don't want medical devices to become commodities, which typically have very thin profit margins, so they lobby for stricter and more onerous safety standards, even if the safety isn't actually improved.

  5. There are, in fact, electrodes attached directly to your skin by necessity, and the better the contact, the better the ECG signal, but also the greater the risk of lethal shock.

That being said, an opto/RF-isolated and battery-powered Arduino ECG would be pretty easy to do, just requires more time and complexity. But once you have that figured out and the design open-sourced, it should be pretty easy for others to replicate (can you do infrared serial with an arduino? it sounds doable, and would be a pretty cheap solution to opto-coupling). Also, you can get a pretty good measure of safety by merely hooking the Arduino into a laptop running on battery, not AC. Problem (mostly) solved!

Anyways, I've also though of adding a SPO2 sensor, a thermometer, and maybe some sort of digital stethoscope (so you could also do a sort of phonocardiogram... though it would take more bandwidth on the serial port, and thus would take more careful coding and more development time)... all in one device. Hook it up to an XBee or Bluetooth shield (or an SD card shield for recording), and you have yourself a very cheap device that can do all sorts diagnostic tests. Such a device, even with all those options, could probably be mass-produced for less than $100 (including bluetooth) and could integrate with cellphones (ubiquitous even among the poor in the third world) and the data shared all around the world with specialists.

I would really like to integrate an ultrasound device, but that is considerably beyond the processing power and/or bandwidth and/or sampling rate of an Arduino. BTW, what is the highest analog sampling rate of any hobby-like chip that is available that has a pretty accessible and high-bandwidth interface to a PC?