This ECG (Electrocardiogram) unit has an integrated display. The display can show individual heart beats in a large format, the train of heart beats in a small format and a Poincaré plot.
It is battery powered and can be worn round your neck on a lanyard.
It is built from an AD8232 module (£7 with leads), an Arduino Nano (£3) and a 2.8″ TFT display (£6) plus a few resistors, a pushbutton and so on – the sort of things you already have. For power, you can use 4 AA cells or a single Lithium cell.
You might be interested in your heart during the Covid-19 pandemic. Covid-19 can sometimes give rise to cardiac complications including arrhythmia, ischaemia, infarction, tachycardia and conduction problems. But by the time that happens, you’re probably lying in an intensive care ward.
Step 1: Safety and Medical Disclaimer
Here’s some legal blurb and a discussion of electrical safety. The most important point is do not operate the circuit when it’s plugged into a PC which is plugged into the mains. Oh yes – and don’t blame me if you kill yourself.
I am not a medical professional. This Instructable was created for information purposes only. It does not describe a medical device. The information given here is not intended to be a substitute for professional medical advice. If you think you have a medical condition you should contact a qualified health professional. If you think you have a medical emergency you should contact your local emergency services. The device described here is not a substitute for professional medical diagnosis, ECG interpretation or treatment. You are encouraged to confirm any information in this Instructable.
As I have no control over how you build the electronics described here, I cannot guarantee its safety as a medical device. I think it is perfectly safe for me to use but you should make up your own mind. It’s running off 4 AA cells or a single Lithium cell for goodness sake – how dangerous can it be?
If you have been fitted with an internal defibrillator or pacemaker, do not attach electrodes to your body and mess about with circuits.
Professional medical electronics should conform to IEC 60601. I have designed medical electronics in the past but it was a few years ago. I seem to have lost my copy of IEC60601 which is annoying as you have to pay for it. Would this device get IEC 60601 approval? How safe is it?
IEC 60601 is a huge document. The most interesting questions to an electronics designer are:
- how much current can I pass through the patient?
- what electrical isolation is required?
- what happens if a “component” fails?
- how much electromagnetic interference can I produce?
- what about a defibrillator?
How much current can I pass through the patient? In “Normal Working” operation the current limit is 100uA a.c. and 10uA d.c. and in single fault condition it is 500uA a.c. and 50uA d.c. This circuit would be classed as an “Applied Part”.
I don’t know what circuit the manufacturer of the AD8232 module has used. When I examine the one I have, it appears to be one of the circuits in the “Application Circuits” section of the AD8232 datasheet.
The input impedance of the chip pins is 10Gohm so the “Normal Working” operation the current is under 1nA.
The electrodes are connected to the chip through 180k resistors. The chip operates at 3.3V so if the chip goes wrong, the maximum current is 3.3/180k = 18uA.
So the chip and its circuit is safe so long as it’s battery operated.
What electrical isolation is required? An “Applied Part” has to be double isolated at 4000VAC. Your desktop PC is not electrically isolated to that degree therefore you should never operate the circuit when it’s plugged into a PC which is plugged into the mains. A standard PC power supply almost certainly does not comply with the electrical IEC 60601-1 requirements from several standpoints, e.g. leakage current, dielectric strength.
Can you operate it when it’s plugged into a PC which is running on batteries? It wouldn’t be allowed for a medical device but for a domestic device it probably would be allowed. (Domestic regulations are less stringent.)
Did I operate it when plugged into a PC which was plugged into the mains? I’m not saying. I’ve been using desktop PCs for decades and have never got a shock off one. I’m just telling you that you shouldn’t do it.
Would the circuit’s isolation conform to IEC 60601? If it were battery operated then that’s one layer of isolation. Where’s the second layer? I guess maybe you’d need two insulated boxes one inside another. IEC 60601 sometimes seems a little silly.
The circuit should have no exposed conductive surfaces that are connected to the electronics. You have to worry about electrostatic discharge: what it the patient rubs a balloon on their hair then touches the box?
The patient shouldn’t be able to touch the electronics or the battery or whatever. Yes, I know you’ve never got a shock off a 6V battery – I’m just telling you the regulations.
Electrical isolation also depends on the creepage distances on the PCB and air clearances. The AD8232 module uses 0603 resistors on its input. An 0603 doesn’t have sufficient creepage.
Is the electrode connector suitable? No way. It’s a 3.5mm stereo jack plug. You could tape the electrodes to your chest then poke the jack plug into a mains outlet. I don’t know why you’d want to but you could – right?
What happens if a “component” fails? IEC 60601 says that the device must remain safe under a ‘single fault condition’. A medical device must operate safely not only in normal conditions, but also in abnormal and single fault conditions. The standard does not require that the medical device remains safe with two or more independent faults. A “fault” is typically a component failure.
What counts as a “component”? I have no idea. You could go through each of the electronic components and say “what happens if this goes short-circuit?” and “what happens if this goes open-circuit?”. Is the PCB a “component”? How can it fail? Can it suddenly re-arrange itself and connect battery to two electrodes? I can’t find a definition of a “component” or “fault”.
If it’s battery operated and a “component” is an electronic component like a resistor or an IC then the circuit is safe.
How much electromagnetic interference can I produce?EMC is a big problem when designing medical equipment. Hospitals are full of electronic stuff that people’s lives depend on so the EMC requirements for medical equipment are a lot tougher than for domestic electronics.
I have no idea how much EMC the board produces. The biggest culprit is probably the Arduino. I’ve never had an Arduino interfere with a TV or cellphone but I suppose it might.
In theory, you should put the circuit in a Faraday cage and worry about what wires go in and out. In practice, I don’t suppose you’ve ever thought about EMC when you build an Arduino circuit, have you?
What about a defibrillator? So you’ve built your medical electronics and done the safety analysis and then IEC 60601 has one more surprise for you. Your circuit has to survive a defibrillator.
What is the standard for a defibrillator? I couldn’t find one. Each manufacturer decides for themselves and the physician can decide what to apply. Shall we guess a capacitor charged to 300V containing 300 joules? That’s connected to your chest somewhere near the ECG electrodes. I suspect that will fry the circuit. IEC 60601 says that the device must remain safe – it doesn’t say that it has to continue to work.
A proper medical ECG can survive a defibrillator and go on working. Normally, you would have some protection diodes on the connections to the electrodes. The AD8232 module doesn’t have them.
The bottom line is: you could make this circuit into a medical device that would conform to IEC 60601 but it would be a lot of work and testing and certification would be a huge expense. This is just a circuit you’re building for fun.
See here and here for discussions of the dangers of a small battery. I have measured the resistance between the electrodes as 150k so, in the worst case, a 6V battery gives a 40uA current – well below the milliamps needed for a battery to be dangerous.
Step 2: AD8232 Module
The AD8232 chip contains a high quality, low noise instrumentation amplifier and signal conditioning to remove noise. It is intended primarily for recording ECG and takes a lot of the hard work out of designing a system.
Buy a module like the one in the photo. Search eBay for “AD8232 module” or “ecg module”. For convenience, get one with leads and electrode pads.
Connect it to an Arduino Nano (or Uno or Mini with a 16MHz 328P) as shown above. I used a solderless breadboard.
The AD8232 includes “leads off detection”. If either lead is disconnected, the LO+ or LO- pins of the module go high. For initial testing, I connected the LO+ and LO- pins to two LEDs though 1k resistors to ground. The LEDs light when a lead is disconnected. For the final circuit, remove the LEDs and connect LO+ and LO- to the Arduino. Don’t leave the LEDs connected – the AD8232 pins won’t go high enough for the Arduino inputs to register HIGH.
Download the ArdECG0.ino sketch and upload it to the Nano. Connect the Nano to a PC running on batteries. In the Arduino IDE, select the Tools|SerialPlotter menu command. Set the baud to 57600.
With the module I bought, the electrode leads are coloured:
- LA Left Arm: Green
- RA Right Arm: Red RL
- Right Leg: Yellow
Yours may be coloured differently. Which lead is which? try touching the leads together:
- Non touching: both LEDs lit
- LA touching RA: both LEDs lit
- LA touching RL: LO+ LED is off
- RA touching RL: RO- LED is off
My module came with only 3 sticky electrodes. They’ll get used up quickly so I decided to make my own. I happened to have some of the popper connectors left over from another project. I used tinplate for the electrodes themselves. Copper coins work as well but tarnish more quickly and stain your skin. As electrode jelly, I mixed thick shampoo and salt. I stuck them onto my chest with masking tape – it would last a few hours.
Attach the electrodes as shown in the picture above.
- LA to the left side of your chest below the clavicle (collar bone)
- RA to the right side of your chest below the clavicle
- RL somewhere low down away from the heart
The RL electrode is called “Right Leg” but it doesn’t actually need to be on your leg. It’s a reference electrodethat reduces common-mode interference. Anywhere well below and away from your heart is fine. The lower-left of the abdomen is good. Try to avoid muscles – their movement and electrical activity could interfere with the signal.
Google for “ecg 3 lead electrode placement” for other diagrams.
Step 3: Fake Pulse
The ArdECG0.ino sketch can produce a fake “pulse”. It’s not a very realistic fake but it produces pulses of about the right size at about the right frequency. It’s convenient to use it when debugging your unit.
The 100k resistors persuade the AD8232 that there are electrode attached. There are some pads on the AD8232 module PCB labelled RA, LA, RL. I just poked some wires into them.
Step 4: The Heart
Doctors think of the heart as a complex organ but to an electronics designer, it is simply a generator of electrical potentials – several tens of millivolts.
The pulse travels slowly to the muscles of the atria and to the atrioventricular node (AV node). The muscles of the atria contract and then relax. As they contract, they pump blood into the ventricles. As they relax, the atria take in blood through the veins from the body or the lungs.
The AV node delays the pulse (by 120-200mS) then sends it to the muscles of the ventricles. Electronically, it too is a relaxation oscillator but its period is much longer than the SA oscillator. It is “prematurely” triggered by the SA oscillator so they become entrained. If the SA oscillator fails, the AV oscillator can oscillate on its own as a backup system.
The muscles of the ventricles contract and then relax. As they contract, they pump blood to the body or the lungs.
The whole process takes around 500mS.
It takes more power to pump blood round the body so the biggest signal we see is from the muscles of the left ventricle.
Sodium, potassium and calcium ions are pumped across the membranes of the cells of the heart muscles. When a heart muscle is relaxed, the difference in ion concentrations causes a 90mV potential difference across the cell membrane. Inside the cell is more negative.
When an action potential occurs a muscle contraction is triggered, Sodium channels open, Na+ ions rush into the cell by diffusion and the voltage goes to zero. That’s called “depolarisation”. After a 100mS delay, potassium channels open, K+ ions rush out of the cell and re-establish the 90mV resting potential. That’s called “repolarisation”. Ion pumps then restore the ion concentrations. (Calcium ions are also involved but I’m ignoring them.)
When an action potential occurs in a cell, the cell next to it is triggered. So the action potential spreads through the muscle and also via the Purkinje fibers. It’s a slow process; no fast nerve conduction involved.
- Muscle cell conduction is 0.3–0.4 m/s.
- Purkinje fiber conduction is 2–3 m/s.
- Normal neuron conduction is 70-120 m/s.
Purkinje fibers can oscillate by themselves at 20-40 bpm and so act as a backup system if the SA and AV oscillators fail.
An ECG records the action potentials of the different muscles. The action potentials of the muscles are transmitted through the chest wall and skin by simple electrical conduction. So the conduction is fast. By the time it reaches the skin the signal is around 1mV.
Because different action potentials occur in different regions of the heart, by repositioning the ECG electrodes you can record activities in different muscles. With the electrodes at the left and right under the clavicles, you’ll get the classical PQRST shape you see in a textbook (called “Lead I”). If you position the electrodes elsewhere you can pick-up other details of heart activity; different positions for pairs of electrodes are called “axes”.
It’s confusing, when doctors talk about “leads” and “axes”. When they say “lead”, they don’t mean a lead – i.e. an electrode. Remember, what an ECG displays is the difference between two electrodes – it’s a differential amplifier. The LL or RL electrode acts as a ground to help with common-mode rejection. A “12 Lead” ECG has 6 electrodes called V1 to V6 which are in a line in front of and to the bottom-left of the heart. Then there are RA and LA near your armpits. There may be two reference electrodes: LL and RL; the extra one doesn’t seem to do much so there’s usually just one. Pairs of electrodes are also called “leads” – LA-RA is called “Lead I”, LL-RA is called “Lead II” and LL-LA is called “Lead III”. It’s a mess.
The correct placement is:
- V1 is placed on the 4th intercostal space on the Right side of the sternum
- V2 is placed on the 4th intercostal space on the Left side of the sternum
- V4 is placed in the 5th intercostal space in a perpendicular line from the left nipple
- V3 is placed between V2 and V4
- V6 is in the 4th intercostal space in the left mid-axillary line (from the armpit to the hip)
- V5 is placed between V4 and V6
(Right and Left are patient Right and Left. On most males, the 4th intercostal space is between the nipples and is the indentation or soft area between the ribs.)
The maths is:
- Lead I: LA – RA
- Lead II: LL – RA
- Lead III: LL – LA
- Lead aVR: RA – average of (LA,LL)
- Lead aVL: RL – average of (RA,LL)
- Lead aVF: LL – average of (RA,RL)
- Lead V1: V1 – average of (RA,RL,LL)
- Lead V2: V2 – average of (RA,RL,LL)
- Lead V3: V3 – average of (RA,RL,LL)
- Lead V4: V4 – average of (RA,RL,LL)
- Lead V5: V5 – average of (RA,RL,LL)
- Lead V6: V6 – average of (RA,RL,LL)
The different “leads” are like looking towards the centre of the heart from different directions in 3D (see diagram above). The directions are called “axes”. To add more confusion the heart also has an “axis” – the electrical activity is symmetrical about that axis. If part of the heart goes wrong, the heart’s axis might have “deviation”. If “leads” I, II and III look roughly the same, that’s normal; if they’re different, that’s “deviation”.
Broadly, what can go wrong with the whole system is that the nodes (oscillators) or the different muscles stop functioning properly. For instance, parts of the muscles might be starved of oxygen and they don’t produce an action potential. Or the SA node might run at the wrong rate or the SA and AV nodes might become disconnected and the oscillators run at different rates.
Source: ECG Display With Arduino