DIY ECG EKG Portable Heart Monitor




Introduction: DIY ECG EKG Portable Heart Monitor

Trying to capture a trace of my very occasional heart palpitation has proven to be nearly impossible. Being keen on electronics, I thought I would make my own ECG (ElectroCardioGram) monitor.

This is intended to be a fun project, not a replacement for a proper ECG. A hospital ECG will likely be a "12 lead" monitor (which actually only has 10 leads due to sharing). This monitor has just two leads, which are placed over bony areas of the chest (sternum and lower-left rib).

The project was fun - circuit design, PCB manufacture, Arduino coding, datalogging, LCD screen, 3D printing, data analysis, etc.

This is not intended to be a full, step-by-step guide. I think you really have to know a little bit about what you are doing in each area listed above. I will try to give enough information to give people the confidence to have a go. There is nothing particularly hard here. This is not a finished, polished piece of kit - more a fully-working prototype.

The finished project, consists of a portable plastic box, with a colour LCD screen which shows the live ECG trace. It has connectors for the electrodes and has a slot for a micro SD Card which stores the data. There are four AA cells inside the box - it is fully self-contained. It has a real-time clock so that the heart data can be labelled with time-of-day and date.

The SD Card holds the voltage data which forms the ECG trace. There is no indication of absolute voltage, but there is an accurate 1-second time-base embedded in the data. The data is stored as a plain text string of numbers, each on a separate line (ie CSV). It imports straight into a spreadsheet.

Safety is paramount, don't put electrodes on your body when they are in electrical contact with ANYTHING connected to the mains (including the USB Arduino Programming lead). Be wary of similar projects which use a serial monitor to display the results - possibly connecting your body to the mains via a USB lead.

Disclaimer: Never connect this project to your body without having the finished project comprehensively checked by a fully-trained medical equipment technician. Ask him/her to issue you with an electrical safety certificate.

December 2021 addition:

If you are thinking of making this sort of project - take a look at this Instructable published in March 2021. It might be good....

Step 1: Overview

The diagram shows the basic functionality.

The photograph shows the main commercially bought modules (Left to right: Real Time Clock; ECG Front End; Colour LCD Screen; Arduino Pro Mini; OpenLog; Battery Holder)

ECG Front End

The whole project is built on an ECG front end available from "100RandomTasks" (cost=22CAD, around £13 GBP)

This brilliant, tiny circuit board, does all the hard work in processing the minuscule heart signals, rejecting the electrical noise, and amplifying the heart trace signal to a voltage which is perfect for feeding into an Arduino. It is possible that an alternative would be the AD8232 heart monitor module which has become available.


The Datalogging aspect was very simply achieved using an "OpenLog" circuit board - available from lots of suppliers (£4 from China £12 from UK) - just search for OpenLog in Google an/or Ebay. OpenLog does everything necessary to put the data onto the SD Card. The SD Card holds the heart's voltage data which forms the ECG trace. There is no indication of absolute voltage, but the Arduino provides an accurate 1-second time-base which is embedded in the data. The data is stored as a plain text string of numbers, each on a separate line (ie CSV). It imports straight into a spreadsheet. OpenLog is an absolutely brilliant tool for getting virtually any data onto a Micro SD card - fantastic.


Most people are interested in the minimum cost. If you buy everything on ebay and order from China the main components cost (2018 prices)

  • £5.20 TFT display
  • £2.25 Real Time Clock module
  • £1.50 Arduino Pro Mini
  • £3.50 OpenLog
  • £13.00 ECG Front End (from Canada)

There is now an AD8232 heart monitor available for £3.60 from China which might be an alternative to the ECG Front End that I used.

Chinese rip-offs are not recommended, especially if you want guaranteed quality components and make use of library code developed by the original suppliers who deserve support.

Obviously, there are other costs:

  • SD Card
  • Discrete components, connectors and batteries
  • PCB manufacture materials
  • 3D print materials
  • Medical grade electrodes

It is quite a while since the parts were purchased - study the photo of the modules to see what was used here - there is nothing 'special'.

Step 2: Circuit Design

As you can see from the circuit schematic, most of the circuitry is dealt with by the plug-in modules and doesn't appear on my schematic. All of the purchased modules (RTC, ECG, Arduino, OpenLog, TFT) simply plug onto the connectors on the schematic. There are also connectors for the on-off switch, two buttons, batteries, etc.

The schematic contains two errors.

  • Note 1 - the TFT requires 3V signals, but the Arduino runs at 5V. I have put a simple (!) potential divider circuit made up of two resistors to drop the voltage. Somehow I got the wiring wrong - doh! I corrected the mistake by slightly rearranging the layout of the resistors when I soldered them onto the board. The necessary correction is shown in the second diagram, just swap A for A, B for B, etc.
  • Note 2 - The ground pin 10 from the Arduino, should go to ground! Again, corrected by tweaking the PCB (Must have been a late night)

The heart signal voltage output is read by one of the Arduino's analogue input pins. The RTC, TFT and OpenLog all have serial communications with the Arduino. There is provision in the circuit for the Arduino to use an external voltage reference from a zener diode, instead of the internal reference voltage. This was never used and the components were not fitted.

To reduce current consumption, the LEDs in the TFT display can be switched off by one of the pins of the Arduino and an accompanying VFET.

The 'usual' prototyping on a breadboard was carried out to check on the way in which the various modules work. The photos show the RTC, TFT and OpenLog being checked-out.

Step 3: PCB Design and Manufacture

KiCAD was used for the circuit design. The files are not available here because there are so many dependencies (custom parts, custom pinout designs, libraries, etc) that too many individual files would have to be supplied.

The PCB is a single sided design with the components and six wire bridges on the top side and the tiny VFET soldered on the copper side.

The PCB was made with a UV sensitive resist board and a transparency with the traces printed on.

The resulting copper layer was mediocre and required some patching - not my best work, but functional.

A PDF of the final board design is supplied (but remember the circuit errors noted in the previous step). The dimensions of the fine black line surrounding the artwork (ie the board cut-line) are 85.04mm x 68.38mm

Step 4: Assembling the ECG

The assembly of the PCB was pretty straightforward. The design is pretty tight for space, but worked really well.

Step 5: 3D Printed Case

The free version of SketchUp was used for designing the 3D Printed parts, and then exported as STLs.

There were three parts, a lid, the main box and a belt hanger (which has not yet been fitted).

One very pleasing aspect was the inclusion of a 'knock-out' area for fitting the main power switch. This was printed with a thickness of 1mm and was easy to cut out with a knife (but was invisible without a backlight before it was cut out and hence, could have been left unused without spoiling the lid).

Also, a centre-line and 'pilot mark' was included for the fitting of the push button switches.

All these aspects are easy to add to the 3D model, and save lots of hassle when trying to cut and drill the case.

Step 6: Arduino Software/Sketch

The Arduino software grew in a rather iterative manner! It is not particularly pretty, but like every aspect of this project, I wanted a working solution as quickly as possible.

The software still includes debugging code, which is currently turned off with a 'debug' variable flag.

Once the software is running in datalogging mode, it simply reads the analogue voltage presented by the ECG front-end and sends it via serial link to OpenLog. In use, the values range between 50 and 700. I could have increased this range/resolution nearer to 1024 by adding an external voltage reference.


The most interesting aspect (?) is the timing element. Regular and reliable timing is tricky for a device like this due to different delays which get introduced by different parts of the program. As soon as the TFT is in use, the looping slows dramatically, so when collecting data with OpenLog, the TFT is not updated and it is blank. When datalogging, the finished ECG takes samples at a rate of better than 190 per second (around every 5 thousandths of a second), which is fine.

Timing must be regular, and a 'marker' of some sort was required so that the regularity could be measured and checked. This was achieved by using an interrupt handler which was triggered every second by the internal Timer1.

All the interrupt handler does, is set a 'flag' called InsertZero, it then lets the software carry on. In the main loop, the flag is tested and a zero is sent to the datalogger when the flag is set. As the miniumum value of the real heart data is about 50, the zero value is easily picked out as a '1 second marker'.

Programming interface

Having been 'bitten' before, right from the initial design, I made sure that the programming pins of the Arduino would be accessible once the project was assembled and running.

Step 7: Displaying the Data

The data is displayed on the TFT screen, but to get something on paper requires some analysis.

The data is saved by OpenLog in CSV format and can load straight into Excel (etc) and inserting a 'scattergraph' shows the data with virtually no effort. The Excel image shows this. The data is upside-down compared to a 'normal' ECG. The one-second markers can clearly be seen. This has lots of drawbacks - mainly getting it to look anything like a real ECG is very tricky, and getting more than a few seconds of data displayed is very awkward.

Microsoft Small Basic Analysis

Embarrassingly, Microsoft's Small Basic is my go-to tool for quick-and-dirty data analysis! The output shown in the image is about 150 lines of trivial Basic code. It is so easy to draw the grid, open the data file, read the data, invert the data, plot the data in four rows, add labels, add a 1 second marker, etc. All with instant running, no waiting for compiling - it's an absolute breeze, and so powerful! The Small Basic Program is included here - it will need Small Basic to be installed on your PC and reads the data from a CSV file (called DataToPlot.CSV) which must be in the same folder as the Small Basic program. A few seconds of example data are included here (they show a fast and irregular heartbeat!)..

Step 8: Putting It All Together

Connecting Lead

An old audio lead is used for the connections. Only two of the leads are actually used - the white lead was intended to be an 'earth' connection on a wrist or leg, but it never seemed to function, so it is not used.

Lead positioning

The diagram shows the positioning of the leads. The relevant ones for a two-lead set-up are labelled RA and LL. (The diagram is for a 3-lead set-up but RA and LL are right for the arrangement used in this Instructable - diagram from )


The electrodes are easy and cheap to purchase. They have a wet sponge in the middle. The ones pictured are single-use "Ag/AgCl electrodes".

Electrical Noise

The voltages the device measures are tiny. Being a battery-powered device avoids lots of electrical noise. It is sensible to keep away from equipment which radiates lots of electrical noise.

Battery Life

The device takes about 60mA when running. This is reduced when datalogging. No real attempt has been made to reduce consumption - it is only used in short bursts. The Duracell data sheet suggests that the AA cells should last around 40 hours at this discharge rate.

The Real Time Clock has a 2032 cell on board. This is still going strong after being around for a few years without much use (I believe it trickle charges when the board is connected up?).

In Use

The electrodes are stuck onto the chest. The leads clip onto the electrodes and plug into the ECG.

When switched on, a reminder screen is shown. The Real Time clock only needs setting once in a blue moon. If one button is held down - the software switches to a 'clock setting' mode, where each time element (year, month, day, hour, etc) is set by a button push.

If the alternate button is pressed, the TFT displays the heart beat ECG trace. This enables the user to check that the trace looks OK, and generally be happy that it is working. At this point, pressing the two buttons simultaneously triggers the datalogging to begin - and the TFT goes blank. Pressing the two buttons again, will stop the datalogging and restore the TFT trace.

Trying this yourself

I repeat, that many elements of this project could be improved. I really just needed a tool to do a job, and I stopped fiddling as soon as the bit I was working on actually worked.

That said, this seems to be a really good prototype, with a truly useful function. It is ripe for improvement - hence this Instructable.

Note the disclaimer on the first page!

2 People Made This Project!


  • Digital Fabrication Student Design Challenge

    Digital Fabrication Student Design Challenge
  • Make It Modular: Student Design Challenge

    Make It Modular: Student Design Challenge
  • Science Fair Challenge

    Science Fair Challenge



Question 5 months ago


I'm currently working on this project and would like to know what Diode and Zener diode you are using.



Answer 5 months ago

Hi Sam

Thanks for your interest.

D1 is any small indicator LED.

D2 is a simple battery-reverse-connection preventer - eg 1N4001, etc - virtually any regular silicon diode will do - It also drops a small voltage (0.6V) which I thought would keep the absolute maximum rail voltage below 6V - The 5V version of the Pro Mini has never had a problem using this set-up (I have never tried it without the diode in place - I thought that with four fresh alkaline batteries, each at 1.6V the resulting 6.4V might be too much??? - hence including the diode for protection and voltage reduction).

D3 was never used and was only included on the off chance that I needed a calibration voltage on pin 21 of the Pro Mini. With the Aref jumper installed, a 'known' voltage (eg 2.1V from the zener diode) would be presented to the Pro Mini for use by the software. It wasn't needed and was not used - so R2, R16, D3, Aref connector, were all omitted.

I hope this helps - I'm afraid that this Instructable was not ever intended to be a "How To", hence no list of components, etc. You can see from the photos of the temporary plugboard circuits, that I slowly added the modules, getting each bit working before adding the next - eventually, the final design came together.

Best of luck - I hope you get something useful working!


Reply 5 months ago

Thanks so much! It's a fun challenge to build the project without the "How To" regarding my skill level. Fingers cross everything else goes without a hitch :)


1 year ago

Hi, I also have an intermittent heart skip once in a while. Did this work for you to discover your heart problem?
I am going to try to build it. Do you have anything new to add in the seven years since you designed it?
many thanks


Reply 1 year ago

Yep - it worked well, and continues to perform well. The printout from it did lend credence to my assertion that my heart 'flipped' into an irregular rhythm on numerous - but infrequent occasions (perhaps once every few months, with episodes lasting a few hours). I think I only managed to get to a hospital on two occasions where they were able to put an ECG on me and get an 'official' confirmation of the irregularity.

A few years ago, I had an ablation operation to 'damage' the heart nerves which cause the irregularity. I have been clear of any episodes since then (until a couple of weeks ago after having a Chinese meal - full of MSG? - very annoying - last Chinese meal I have).

Getting a printout is tricky, but proved useful for me. Loading the data into Excel and creating a 'scattergraph' will be enough to show the irregularity, but the information in Step 7 should help.

I'm pretty sure that there would be some tweaks, if I started making it today, as there are some good display options, etc. But I'm more than happy with it as it is.

I hope this helps. Best of luck.


Tip 1 year ago

Great project!! The only real improvement I would add would be tuning the ST segment a bit. Since it's not a 12 lead, it would be a little harder to do that.

ST segments can show ischemic issues to the heart like angina and heart attacks but the st segment on here isn't too off and can be interrupted as normal still. Anyways, very elaborate!


Reply 1 year ago

Many thanks for your comment. A 12-lead ECG is definitely the Rolls-Royce version. Due to the fact that they are properly calibrated, I know that the doctors can make very detailed conclusions from them.

Thanks for your interest.

Best wishes


2 years ago

hello sir..First of all, This project is amazing. I really appreciate it that you share it..I made it, and now i just stuck in 1 step.
The Arduino programing..
As you share the software, i download it but i can not upload it..
Sir could you help me and guide me what should i do?
So many thank you for this amazing project,once again.

also this is the Error of uploading

Arduino: 1.8.10 (Windows 7), Board: "Arduino Pro or Pro
Mini, ATmega328P (5V, 16 MHz)"

Multiple libraries were found for "SPI.h"

ECG_Software_02:18:10: error: Adafruit_GFX.h: No such file
or directory

Used: C:\Program



compilation terminated.

exit status 1

Adafruit_GFX.h: No such file or directory

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

Best regards.


Reply 2 years ago

Hi there. Thanks for your interest.
It looks as though you do not have the graphics library installed in your Arduino setup.
It's a little while since I have done any Arduino stuff, so can't quite remember where the header files are installed, but a quick Google should let you know where.

I think the source of the files is at:

Click on the "Clone or Download" button then "Download Zip". This will download the whole library onto your computer downloads folder. I think you can install the lot in your Arduino setup. When you recompile your (my) Arduino sketch it should then find the header file (Adafruit_GFX.h) and include it, hopefully finishing compiling correctly.
Let us know how you get on. Best wishes


Reply 2 years ago

Hi..thank you so much for your information.
you were right, and after download the library , the code fixed.
although i had to change some because my RTC and ECG are another Model.
but again,so many thank you,
i hope there will be no problem happen again and can fix it completely,
best wishes


2 years ago

Hi. This Project is amazing and im trying to make it one, but i need some help and i would really appreciate if you can help me.
which LCD should i use ? (TFT-LCD-ST7735) is good?
and do you have any map of circuit so i could use it and make the board? or the file of the circuit?


Reply 2 years ago

Hi. I used a "2.2 SPI TFT LCD ILI9341" and these are available on eBay for £5 (GBP), they have a resolution of 240x320px. Your "TFT-LCD-ST7735" looks to be a smaller series of displays (the 0.96" one only has a resolution of 80x160, the 1.8" one looks like a 128x160px resolution).

There are 2.4" and 2.8" versions of my display on eBay both with 240x320 resolution for a little more money than the 2.2" version. I don't think I would go with a smaller resolution than 240x320. If you stick with ILI9431 display, then the arduino software I link to should work without alteration (you will need the ILI9431 library installed on your PC in order to compile the code).

There is an overview of the circuit in Step 1 and a more detailed circuit diagram in Step 2 and the PCB track layout is ready to print onto a transparency as a PDF in Step 3. However, you do really need to have a little bit of background in these electronics modules to make this device. I would highlight what I said in the introduction:
This is not intended to be a full, step-by-step guide. I think you really have to know a little bit about what you are doing in each area listed above. I will try to give enough information to give people the confidence to have a go. There is nothing particularly hard here. This is not a finished, polished piece of kit - more a fully-working prototype.

I designed the circuit in KiCad, but the learning curve is steep and the PCB design relies on several footprints which I designed (as I couldn't find readily available ones). The whole set of footprints, libraries, and files is a bit of a nightmare in KiCad, so would be very hard to package up and supply via the internet.

I really treated this project as a learning exercise and made various mistakes along the way. I 'honed' my abilities in 3D printing, PCB design and manufacture, Circuit design, Arduino code, electrode use, etc, etc. I got each element sorted one-at-a-time in a simple way, then brought two elements together, then three, etc, until the whole project was finished. I think you may have to treat the project in a similar way.

I hope you are successful. Let me know if there is anything else I can help on.

Best wishes


Reply 2 years ago

Thank you so much for your guidance. I really appreciate it.
I found the LCD and it is much better than i chose, thank you, i will get it.
as matter of fact i'm a student (Bio Medical Engineer) and i wanted to offer Heart holder as a project and after some searching i found your amazing work and i really interested in it. but unfortunately i have really short time and i never worked with KiCad or designed circuit. that is why i asked for your help and PCB File.
Now i just programing the Arduino with program you shared and start to make the Circuit.
Do you use any IC in Ciruit? cause i saw 1 IC in one of sreenshot.
Also can you tell me the length and width of the PCB circuit?
With best regards


2 years ago

You've got actually great signal quality! We were working on our ECG device ( ) for a while, and even with well optimized PCB it wasn't easy to reach high quality (mains noise still gets through) - and you did it with a bunch of separate modules!


Reply 2 years ago

Many thanks for the comment. All down to the ECG Front end from 100RandomTasks I suspect.

Best wishes


4 years ago

Parts list is lacking - need to define parts used else make it hard to find the exact right things.


Reply 4 years ago

Ebay descriptions below

- Pro Mini ATMEGA328P 5V/16M Arduino

- Openlog Serial Data Logger Open Source Data Recorder Micro SD Support

- 8GB Micro SD High-speed TF Adapter Memory Card for Cell

- Arduino RTC DS1302 Real Time Clock Module For AVR ARM PIC SMD

- 10X Round Replacement for Massager Tens Units Electrode Pads Therapy

- New 1PC 2.2 Inch SPI TFT LCD Serial Port Module Display ILI9341 5V/3.3V

- ECG Analog Front End with 50Hz Notch Filter

I found I needed old library for the DS1302 (3/6/2015)

and only one Adafruit-GFX Library in my Arduino Library list

else I would get compile errors.

All works good now, thanks.


Question 4 years ago

What is Q1 the vFet?


Question 4 years ago

I am trying to break this project down so as to allow my High school students the opportunity to understand the whole project. As a first step I was going to attach the electrodes and ECG Front End Unit to and Oscilloscope and look at the waveform. Would you expect a lot of noise and interference in the signal?