Portable ECG Machine




Introduction: Portable ECG Machine

About: I like to learn, like to make, like to share.

An electrocardiogram (ECG) is a test which measures the electrical activity of your heart to show whether or not it is working normally. An ECG can reveal a wealth of information about cardiac regulation, as well insights into pathological conditions. An electrocardiogram can be a useful way to find out whether your high blood pressure has caused any damage to your heart or blood vessels.

If you have any heart disease such as high blood pressure, or symptoms such as palpitations or chest pain you may require a routine ECGs.

Demo Video:

In this instructables I will show you how you can make your own 3 lead ECG machine very easily (no complex circuit!!!).

I tried to keep it very simple so that you can easily reproduce it. No complex circuit, no complex soldering!.

Step 1: Bill of Materials

1. Banana Pi BPI-M1 (shop)

Banana Pi is an open-source single-board computer that is affordable and powerful. It features high performance AllWinner dual-core SoC at 1GHz, 1GB of DDR3 SDRAM, Gigabit Ethernet, SATA, USB, and HDMI connections. It can run on a variety of operating systems including Android, Lubuntu, Ubuntu, Debian, and Raspbian.

2. 5" HDMI Display (waveshare.com)

This is 5 inch Resistive Touch Screen LCD, HDMI interface, supports various systems like Raspberry Pi, Banana Pi / Banana Pro and BB Black.

3. AD8232 Single Lead Heart Rate Monitor (sparkfun.com)

The AD8232 SparkFun Single Lead Heart Rate Monitor is a cost-effective board used to measure the electrical activity of the heart. This electrical activity can be charted as an ECG or Electrocardiogram and output as an analog reading. ECGs can be extremely noisy, the AD8232 Single Lead Heart Rate Monitor acts as an op amp to help obtain a clear signal from the PR and QT Intervals easily.

4. Sensor Cable - Electrode Pads (3 connector) (sparkfun.com)

This is your simple three conductor sensor cable with electrode pad leads. These cables are 24" long and feature a 3.5mm audio jack connector on one end with snap style receptacles for biomedical sensor pads. Each cable comes in a red/blue/black set.

5. Biomedical Sensor Pad (sparkfun.com)

This is a 10 pack of Biomedical Sensor Pads, disposable electrodes that can be used to measure EEG, ECG and EMG levels. these little pads are perfect for short-term monitoring of Neurofeedback and Biofeedback purposes. They are to be used once and are very handy because of integrated, latex-free gel. Each pad adheres very well to the skin and the snap connector can be pushed on or removed from the electrode lead with no issue.

6. Lithium Ion Battery - 6Ah (sparkfun.com)

I selected a 6Ah Battery from Sparkfun.com. You may use any Li-ion battery. You may also use a lower capacity battery if high backup time is not required.

7. LiPo Battery Manager (sparkfun.com)

This battery management circuit consists of battery charger circuit and a boost converter circuit. You can use separate li-po charger circuit and boost converter circuit. I will show how you can use separate circuits for the project.

Step 2: Hack Your Banana Pi

The Banana Pi M1 is a credit card-sized single-board computers like Raspberry Pi based on a low-cost concept for inner software and hardware development and school software learning such as Scratch. Its hardware design was influenced by Raspberry Pi in 2013. It is produced by the Chinese company Shenzhen SINOVOIP Co.,Ltd.

Banana Pi software is compatible with Raspberry Pi boards. Banana Pi also can run NetBSD, Android, Ubuntu, Debian, Arch Linux, Raspbian operating systems. Banana Pi comes with a dual-core, Cortex-A7-based Allwinner A20 system-on-chip running at 1GHz,. That's much faster than the Raspberry Pi’s 700MHz, ARM11-based Broadcom BCM2835 processor. It also includes a more powerful Mali-400 GPU.

For my project I used Banana Pi instead of Raspberry Pi because it has a built in microphone and much faster than Raspberry Pi. The built in microphone functionality is very important for the project because I am taking ECG signal using audio card and then processing the signal using Python. I tried it in Raspberry Pi using USB microphone but I failed to run the python program due to some audio related issues and then I tried with Banana Pi and it works fine.

Actually the microphone is not required for my ECG project, I only take advantage of built-in audio circuit of the Banana pi board. The signal will comes from ECG circuit and fed it directly to audio circuit. So, remove the microphone fro the Banana Pi board as shown in the photo. Then, connect two jumper wires with the +ve and -ve pad of the microphone. I used the wire from old HDD IDE cable because the wires are thin and insulated.

Step 3: Prepare AD8232

The AD8232 SparkFun Single Lead Heart Rate Monitor is a cost-effective board used to measure the electrical activity of the heart. This electrical activity can be charted as an ECG or Electrocardiogram and output as an analog reading. ECGs can be extremely noisy, the AD8232 Single Lead Heart Rate Monitor acts as an op amp to help obtain a clear signal from the PR and QT Intervals easily.

The AD8232 is an integrated signal conditioning block for ECG and other biopotential measurement applications. It is designed to extract, amplify, and filter small biopotential signals in the presence of noisy conditions, such as those created by motion or remote electrode placement. The AD8232 Heart Rate Monitor breaks out nine connections from the IC that you can solder pins, wires, or other connectors to. SDN, LO+, LO-, OUTPUT, 3.3V, GND provide essential pins for operating this monitor with an Arduino or other development board. Also provided on this board are RA (Right Arm), LA (Left Arm), and RL (Right Leg) pins to attach and use your own custom sensors. Additionally, there is an LED indicator light that will pulsate to the rhythm of a heart beat.

The ECG signal comes from the ECG circuit AD8232 is microcontroller compatible and maximum amplitude is 3.3V which is not safe for the microphone input of the PC audio. Typically the maximum amplitude of a microphone can be 1V. So, I made a voltage divider circuit to reduce the amplitude of the ECG signal from 3.3V to 1 volt. I used a 10K and a 3.3K resistor to make the voltage divider circuit. The schematic is attached below. You can change the value of the resistors but ratio should be same.

Step 4: Connecting AD8232 to Banana Pi

After making the voltage divider circuit, it is time to connect the ECG circuit (AD8232) with the Banana Pi PC.

Connect accordingly:

AD8232 Banana Pi Voltage Divider Circuit

Step 5: Uploading the Python Programs to Banana Pi

This a really cool use of Python! In my project the ECG signal is processed and plotted using python. I lean on some of my favorite packages numpy, scipy, matplotlib, pyqtgraph, and PyQt4. To the the ecg program you first need to install all the packages into your Banana Pi. Follow the instructions below:

Run the following command one by one to install all the packages (I am using python3)

sudo apt-get install python3-numpy
sudo apt-get install python3-scipy
sudo apt-get install python3-matplotlib
sudo apt-get install python3-pyqtgraph
sudo apt-get install python3-pyqt4
sudo apt-get install python3-pyaudio

After successfully installing all the packages, download the zip file named as ecg-program.zip contains all the necessary python files. (The original program is written by Scott Harden. Thanks Mr. Scott for his excellent work in the filed).

Unzip the archive in a directory and transfer the directory into the Banana Pi using any any FTP client like WinSCP. Go to the directory using any serial client like PuTTY and type the following command

python3 go.py

If everything goes OK then a graph will open plotting the data in real time. This time you will get only noise as you don't connect the ecg lead to you body.

Step 6: Making of the Power Circuit

For providing the power to Banana Pi and HDMI display I used Li-ion battery with 2A 5V boost converter. I used a battery from my old HTC phone and it's working well though I didn't test backup time. For more backup time use a higher capacity battery. I connected two micro USB cable about 10cm long to the output of boost converter to power up Banana Pi and HDMI display separately. It is also possible to power up the display using Banana Pi GPIO. I also added a li-ion battery charging circuit with a switch. All the connection are shown in the image.

Step 7: Connecting HDMI Display to Banana Pi

Connect the HDMI display to the Banana Pi using an external HDMI cable before powering Banana Pi.

Step 8: Connecting All the Stuffs

Connect all the components according to the connection diagram. Then connect the sensor cable with the 3.5mm audio jack of AD8232. Use Biomedical Sensor Pad to connect the Electrode Pads to your body. Sensor pad has three lead with different color. Connect the color leads according to the image marked in the photo taken from sparkfun.com. After connecting all the components I enclosed all in a box.

Step 9: The Complete Machine

I added here some photo of my complete ECG Machine. I thing you will like it.

Cardboard Contest 2017

Participated in the
Cardboard Contest 2017

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Be the First to Share


    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest



    Question 3 years ago

    I'm having trouble figuring out where the how the microphone connects.
    I understand that one lead of the microphone goes to the middle of the voltage divider.
    Does the other lead go to ground? In the pictures it looks like it's not connected.
    When I ring out the banana pi, neither of the microphone terminals are grounded.
    In the picture of the voltage divider board, it looks like only one of the microphone leads is connected.
    Anyone else having trouble on this topic.

    It's an awesome project. Thank you very much for sharing this.


    3 years ago

    i am developing an ecg with raspberry pi 3 b + ad8232 and mcp3008, i was wondering if this code works with this hardware.


    4 years ago

    hey guys if anyone is interested I am happy to calibrate it with pro equipment in the A&E department. I have two raspberry pi's 3 if anyone can guide me how to hook them up I am happy to test them and calibrate them


    4 years ago

    Hello, can you help me please, how to use this on PI-3?


    5 years ago

    I am working on Raspberry Pi with ECG so how to connect ECG with
    Raspberry Pi. So please Give me answer with pin number connection


    Question 5 years ago on Step 9

    You have connected ECG with Banana Pi directly through voltage divider but ECG output is analog and Banana Pi understand digital signal so how it is a possible connection ?.
    And you have not shown pin connection number.
    And I am working on Raspberry Pi with ECG so how to connect ECG with Raspberry Pi. So please Give me answer with pin number connection.


    5 years ago

    Impresive! have you done any calibration test against a professional ECG? (to see if the built can be used as an emergency field ECG with a good degree of confidence)