How to Build an Electrocardiogram (ECG)
by Scientify Inc in Circuits > Arduino
1974 Views, 11 Favorites, 0 Comments
How to Build an Electrocardiogram (ECG)
This tutorial will take you through the steps of building a 3-point electrocardiogram using an Arduino.
Before you begin, here’s a little info about ECGs:
An ECG detects your heart's electrical rhythm and graphs them out. This graph is called a tracing and it consists of several waves that recur with each heartbeat, about 60 to 100 times per minute. The wave pattern is used to diagnose various heart conditions. Ideally, the wave pattern should be a recurring one (sample output attached later). A typical ECG machine is bulky and expensive. For developing countries like India which have a high incidence of cardio-vascular diseases, a low-cost portable ECG machine is a boon to make medical facilities accessible in far flung rural areas.
Supplies
- Arduino Uno / Nano
- Male to female jumper wires (5)
- AD8232 module
- 3 electrodes (pad with cable to attach to AD8232 module)
Building the Circuit
Solder pins/wires into the 6 holes (GND to SDN) of the AD8232 IC.
Make the following connections: (Format: Arduino Connection — AD8232)
- GND — GND
- 3.3V — 3.3V
- A0 — OUTPUT
- ~11 — LO-
- ~10 — LO+
~ denotes a PWM/analog pin
Use the attached images as guides to make the connections and to see an example of the final product.
Note: The SDN pin is not used in this tutorial. Connecting this pin to ground or "LOW" on a digital pin will power down the chip. This is useful for low power applications.
Placement of Sensor Pads / Electrodes
Placement of sensor pads (Format: Cable Color — Signal):
- Red — Right Arm (RA)
- Yellow — Left Arm (LA)
- Green — Right Leg (RL)
For the exact placement of sensor pads on skin, have a look at the image attached in this section.
Make sure you clean your skin (with sanitiser perhaps) before attaching the sensor pads.
Also, the closer to the heart the pads are, the better the measurement. Two methods of connecting the pads are given in the image to this section.
Program - Arduino IDE
Please find an attached file containing the code. If for some reason you can't download the file, then here's the code typed out:
void setup() {
// initialize the serial communication:
Serial.begin(9600);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -
}
void loop() {
if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
Serial.println('!');
}
else{
// send the value of analog input 0:
Serial.println(analogRead(A0));
}
//Wait for a bit to keep serial data from saturating
delay(1);
}
Downloads
Uploading the Code to Your Arduino Board
- Connect your Arduino to your laptop/computer
- Choose your Arduino board (Tools —> Board)
- Choose device port where you’ve attached the Arduino (Tools —> Port)
- Compile and upload the code. Then open up the serial plotter (Tools —> Serial Plotter)
Sample Output
Notice the graph is consistent in the image (the waveform is repeating). This means we’re all good.
Thank you!
If you’re looking for an even cooler project, check out my other intractable on how to make rover controlled by hand gestures. Yes, hand gestures! Check it out here: Tele-Operated Rover (Beware! It’s also more challenging) Don’t forget to subscribe to my YouTube channel Scientify Inc. My goal is to make science easy and interesting for everyone.
Please share your comments below. I'd love to hear about your experience while trying out the project! I'll try to reply to all queries within 24 hours.
Social: