How to Build an Electrocardiogram (ECG)

by Scientify Inc in Circuits > Arduino

1998 Views, 11 Favorites, 0 Comments

How to Build an Electrocardiogram (ECG)

sample 2.png

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

  1. Arduino Uno / Nano
  2. Male to female jumper wires (5)
  3. AD8232 module
  4. 3 electrodes (pad with cable to attach to AD8232 module)

Building the Circuit

circuit diagram ecg.jpg
ecg.png

Solder pins/wires into the 6 holes (GND to SDN) of the AD8232 IC.

Make the following connections: (Format: Arduino Connection — AD8232)

  1. GND — GND
  2. 3.3V — 3.3V
  3. A0 — OUTPUT
  4. ~11 — LO-
  5. ~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

ecg_electrodes.png

Placement of sensor pads (Format: Cable Color — Signal):

  1. Red — Right Arm (RA)
  2. Yellow — Left Arm (LA)
  3. 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

ecg_ArduinoIDE.png
sample 1.png
  1. Connect your Arduino to your laptop/computer
  2. Choose your Arduino board (Tools —> Board)
  3. Choose device port where you’ve attached the Arduino (Tools —> Port)
  4. Compile and upload the code. Then open up the serial plotter (Tools —> Serial Plotter)

Sample Output

sample 2.png

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.

@Scientify Inc.

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:

YouTube: Scientify Inc.

YouTube: Scientify हिंदी

Instagram

Instructables

LinkedIn