How to Build an Electrocardiogram (ECG)

Introduction: How to Build an Electrocardiogram (ECG)

About: "Guitar, Gadgets, Gravity My Three G(uru)'s in Life." I'm a high school senior who's passionate about science (and applying concepts to build new things). I run a YouTube Channel called 'Scientify I…

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)

Step 1: 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)

  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.

Step 2: Placement of Sensor Pads / Electrodes

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.

Step 3: 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);

}

Step 4: Uploading the Code to Your Arduino Board

  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)

Step 5: 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.

@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

Arduino Contest 2020

Participated in the
Arduino Contest 2020

Be the First to Share

    Recommendations

    • Make it Fly Challenge

      Make it Fly Challenge
    • Fruit and Veggies Speed Challenge

      Fruit and Veggies Speed Challenge
    • Maps Challenge

      Maps Challenge

    10 Comments

    0
    sky-fish
    sky-fish

    4 months ago

    hi, any chance you can add a sd card to this so it can log data without needing to be attached to a pc?

    1
    Scientify Inc
    Scientify Inc

    Reply 4 months ago

    So essentially you would like to make the device portable, right? Or something like a data logger with the project, while still using a laptop to view the data?

    0
    sky-fish
    sky-fish

    Reply 4 months ago

    yes, i would like to keep it on overnight which would be a problem if the laptop has to stay connected

    0
    Scientify Inc
    Scientify Inc

    Reply 4 months ago

    Yes so you can connect a display to the arduino/raspberry pi. It’s easy to get the output on screen. I’m sure there would be many tutorials available for that (I haven’t made a tutorial for the portable ECG yet).

    As for storing the data on a hard drive or sd card, I’m not sure how to do it on an Arduino but it should be simple for the raspberry pi (storing the matplotlib output if you’re using python on the pi).

    0
    Snake00012
    Snake00012

    Question 1 year ago

    Can we making the graphe on a detached screen
    Can we also print the ecg?

    0
    Scientify Inc
    Scientify Inc

    Answer 1 year ago

    Yeah of course. Great question by the way! You can use a screen to display the output, and also connect a battery to the Arduino in order to make the ECG portable.

    Here are some screens you could use: 3.5” Color TFT or a small OLED screen. The idea is to have a screen which is big enough to display a good amount of data on one screen, while also not being a very restricted screen with only numbers/letters like the 2-line LCD display.

    0
    Snake00012
    Snake00012

    Reply 1 year ago

    Great
    How can I use a bigger screen? Like 6 or 7 inch
    What about the printing process?
    Are we allowed to print from the dashboard?

    0
    Scientify Inc
    Scientify Inc

    Reply 1 year ago

    Hi @Snake00012,
    The only restrictions your screen size are:
    1. Which Arduino you’re using (this decides how many ports you’ll have free for the screen’s connections)
    2. Which screens are available in the market

    About the printing process, should I assume you’re talking about printing the data on the screen and not physically printing it?

    0
    Snake00012
    Snake00012

    Reply 1 year ago

    Understand , thnx a lot
    Great job sir