loading
This instructable shows you how to make an electrocardiograph and a heart rate monitor. It is intended to be a fun science project only. Of course, it should not serve as a medical purpose.

PLEASE NOTE : To avoid any risk of electric shock, only use battery alimentation. Electrodes are theorically isolated from the circuit by the instrumentation amplifier, but play safe. I'm not responsible for any accident that may happen. 

This is a simple design that fits on a single breadboard. You are free to experiment and to custom it for your needs.

Since it's my first Instructable and also since English is my second langage, don't hesitate to contact me if you find an error or if you want some clarifications about a section or another. I will be happy to edit my project for the better!

Step 1: List of Materials

- (1) Instrumentation amplifier INA128
- (1) Operational amplifier 741
- (1) Arduino Uno
- (1) 16x2 characters Liquid crystal display
- (1) Voltage regulator 7805
- (1) 8 ohms mini speaker
- (1) Brigth LED (I use a 10 mm one)
- (1) Diode 1N3064
- (2) 9V Batteries with connectors
-  Breadboard
-  Jump wires
Resistors :
- (2) 100 ohms, 1/4W
- (1) 470 ohms, 1/4W
- (1) 1 kiloohms, 1/4W
- (2) 10 kiloohms, 1/4W
- (2) 100 kiloohms, 1/4W
- (1) 1 Megaohms, 1/4W
Capacitors :
- (1) 10 nF
- (1) 47 nF

For the electrodes :
- About one meter of speaker wire
- Antistatic wrist strap
- Medical tape
- Aluminum paper
- (2) metallic paper clips
- Shower gel (a substitute for electrocardiogram gel)

Optional but recommended:
-Oscilloscope, for the electrocardiography part of the device
<p>Hi</p><p>I used the code provided, added a few modifications to add a filter, as well as a servo motor to act as a analog BPM scale in a 180 degree range. The lcd displays whats programmed but stuck at 30 BPM, and LED does not flash.....which may work once arduino display the proper BPM. Can anyone check the attached code to verify if everything is ok or if there may be something causing these problems? I do get the wave form on my oscilloscope but thats about it right now. You can reply here or email me: codesroc@gmail.com</p><p>Many thanks!!</p><p>[code]</p><p>// This program reads the incoming signal from the electrocardiograph and outputs the heart rate</p><p>// Pin D7 is connected to the signal input</p><p>// Pin D6 is connected to a mini-speaker</p><p>// For the connection to the liquid crystal display, see the LiquidCrystal Librairy</p><p>// External variables</p><p>const int signal = 7; // Pin connected to the filtered signal from the circuit</p><p>unsigned long time;</p><p>unsigned long frequency;</p><p>int angle;</p><p>// Internal variables</p><p>int period = 2000;</p><p>int starttime = 2000;</p><p>int input = 0;</p><p>int lastinput = 0;</p><p>unsigned long death = 0;</p><p>// include the library code:</p><p>#include &lt;LiquidCrystal.h&gt;</p><p>#include &lt;Servo.h&gt;</p><p>#include &lt;Filters.h&gt;</p><p>Servo myServo;</p><p>// initialize the library with the numbers of the interface pins</p><p>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);</p><p>byte heart[8] = {</p><p> 0b00000,</p><p> 0b01010,</p><p> 0b11111,</p><p> 0b11111,</p><p> 0b11111,</p><p> 0b01110,</p><p> 0b00100,</p><p> 0b00000</p><p>};</p><p>void setup() {</p><p> myServo.attach(9);</p><p> Serial.begin(9600);</p><p> pinMode(signal, INPUT);</p><p> lcd.createChar(1, heart);</p><p> // set up the LCD's number of columns and rows:</p><p> lcd.begin(16, 2);</p><p> // Print a message to the LCD.</p><p> lcd.write(1);</p><p> lcd.setCursor(1, 0);</p><p> lcd.print(&quot; bpm : &quot;);</p><p> lcd.setCursor(0, 1);</p><p> lcd.print(&quot;You are &quot;);</p><p>}</p><p>void loop() {</p><p> lcd.setCursor(1, 0);</p><p> time = millis();</p><p> input = digitalRead(signal);</p><p> if ((input != lastinput) &amp;&amp; (input == HIGH)) {</p><p> // If the pin state has just changed from low to high (edge detector)</p><p> period = time - starttime; // Compute the time between the previous beat and the one that has just been detected</p><p> starttime = time; // Define the new time reference for the next period computing</p><p> death = time;</p><p> tone(6, 800, 100); // Output a short &quot;bip&quot; through the speaker</p><p> }</p><p> lastinput = input; // Save the current pin state for comparison at the next loop iteration</p><p> if (period &lt; 0) {</p><p> frequency = 0;</p><p> }</p><p> else {</p><p> frequency = 60000 / period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds</p><p> }</p><p> if ((time - death) &gt; 2000) { // Detect if there is no beat after more than 2 seconds</p><p> tone(6, 900); // Output a continuous tone to the speaker</p><p> // filters out changes faster that 40 Hz.</p><p> float filterFrequency = 40;</p><p> // create a one pole (RC) lowpass filter</p><p> FilterOnePole lowpassFilter( LOWPASS, filterFrequency );</p><p> while ( true ) {</p><p> lowpassFilter.input( analogRead( 7 ) );</p><p> }</p><p> lcd.print(&quot;&lt;30&quot;);</p><p> lcd.setCursor(8, 1);</p><p> lcd.print(&quot;dead! &quot;);</p><p> }</p><p> else {</p><p> char freq[3];</p><p> if (frequency / 100 == 0) {</p><p> freq[0] = 32; // Print a space to the first character if the frequency is below 100 bpm</p><p> }</p><p> else {</p><p> freq[0] = frequency / 100 + 48; // Sort the hundreds character and convert it in ASCII</p><p> }</p><p> freq[1] = (frequency / 10) % 10 + 48; // Sort the thents character and convert it in ASCII</p><p> freq[2] = frequency % 10 + 48; // Sort the units character and convert it in ASCII</p><p> angle = map(frequency, 0, 1023, 29, 179);</p><p> myServo.write(angle);</p><p> lcd.print(freq);//if doesnt work try input or revert back to freq</p><p> lcd.setCursor(8, 1);</p><p> lcd.print(&quot;alive! &quot;);</p><p> }</p><p> Serial.print(&quot;Beats per Minute: &quot;);</p><p> Serial.print(frequency);</p><p>}</p><p>[/code]</p>
<p>Hi,</p><p>Can you tell me if i can use INA 118P?</p><p>Thanks</p><p>Regards</p>
<p>Yes I think it should work fine. Maybe you'll have to adjust the gain.</p>
<p>I added filter code to the arduino library, wrote the filter code prior to frequency calculation in the loop and was able to finally acquire a clear signal....take some palying around with the ds0138 to get the right settings. my problem now is the lcd is still stuck show BPM less then 30. I also added serial monitor to the program and that as well is stuck on 30. I have the input onto digital pin 7 just like the instructions says but not sure what else to do now. I now its probably something simple in the program to correct it. Can you provide some thought on how to fix this. As well i have a servo motor mapped to give a analog scale reading of BPM and mapped out the frequency to a 180 degree range. that as well is not working so it has to do with getting the input back out of the arduino to both servo and lcd.</p>
<p>Hey Birdy,</p><p>Could you please give an explanation of the schematic so that I may understand the circuit better? Also since I do not have the voltage regulator could I just use 5 V from a power supply and get the same output?</p><p>Regards,</p><p>Osman</p>
<p>Hi birdy,</p><p>I have an issue with my circuit as it powers up correspondingly, I must mention that I followed your guide exactly, but unfortunately the LCD display does not show anything, besides the background light. I am using a 3 lead electrode that is connected to the breadboard by an audio jack input, but I added additional cables to the 2,3 pins of the INA128 and the ground electrode to the ground. Can you please tell me what I'm doing wrong ?</p><p>Thank you kindly,</p><p>Filip</p>
<p>I can't see well on the picture but first I suggest you to check your wiring to the lcd, try the example code on the arduino library, like printing hello world on the lcd or I don't remember, something like this, just to isolate the troubleshooting and make this part of the circuit working. Then for the other part maybe check points with an oscilloscope/voltmeter to see if you can get a signal? Often what is happening is that your INA saturates, try to lower the gain first, see if you can get a signal. Sometimes electrodes are not well enough in contact with your skin, try to adjust them till you get something. Good luck!</p>
<p>you may also want to introduce a potentiometer into the circuit that is being fed in the 3rd pin on the lcd. wire your two front pin of the potentiometer for your polarity. this will act as a contrast adjuster. i had the same issue and once i did this i could adjust the contrast of the text on the lcd.</p>
<p>I just recently built this project following the diagram shown. however i am having an issue with the 9v battery that is feeding into the breadboard by the regulator. it is over heating and producing a burning smell. i am wondering if this is a common problem or how i should go abouts fixing this. I am also introducing a servo motor into this project to also create a analog BPM meter but currently trying to figure why its not operating.</p>
<p>If you have any questions. Ask me!</p>
Hi <br>May you send the integrated circuit about this project. <br>Thanks for your help.
Hi,what's this oscilloscope (monitor )model?
DSO Nano oscilloscope V2<br> <br> <br>
<p>hi sophieR23. i had made the project the same way, but the lcd show &lt;30 heart. how to solve this?</p><p>what should i do in troubleshooting?</p><p>already checked the circuit and used same coding..</p>
<p>WOW! It looks awesome! :) Is that gorgeous TFT screen only used for displaying the heart rate? Because you could try to modify my design to sample the ECG signal with the arduino and display it live on the screen! Anyway, I'm interested with the mods you've brought, can you send me a private message? I would love to add your build to my project as an update or something like that, with your permission and attribution of course!</p>
<p>hi author and SophieR23,</p><p>can i use laptop as replace the LCD or oscilloscope? what application i used to display the beat n wave? can i save the data?</p><p>thanks in advance.</p>
<p>Hey birdyberth. The TFT also gives a diagnosis after displaying your BPM. </p>
Hi<br>I don't have diode 1N3064, may I use diode 1N4148 or 1N914?
Hi dear friend. <br>May you send me the arduino code you used for this best project, because I'm going to make it for my school project, please help me, thanks <br>It's my email address. <br>Taha.naroei@yahoo.com
Hi dear friend. <br>May you send me that arduino code you used for this best project. I want exactly that cod because I making this for my school project, please help me. Thanks <br>It's my email <br>Taha.naroei@yahoo.com
Hi, may you say the monitor full name, what's its model?
<p>The oscilloscope is a DSO-nano V2 made by seeedstudio, the LCD is a standard 16x2 character LCD</p>
Thanks sir
Hi,may you say the monitor full name، what's the model?
<p>thamnks dude</p>
<p>Ahh, I've followed and checked each step.. but i want to know that what could be the problem behind &lt;30 bpm infinitely beaming output ??</p>
<p>Hi!! Can you tell me what is the INA128 used for? I mean, what its function in the project?</p>
<p>As SophieR23 says (special thanks to her) the heart rate signal is really small, in the order of 1mV peak-to-peak. The main problem is the noise coming in the circuit through the body, typically in the order of 100mV peak-to-peak or even more, so if you use a standard amplifier, you'll only get noise at the output. The instrumentation amplifier is a badass amplifier who does an amazing job at removing common-mode noise (i.e when the same noise is present on both electrodes), so it amplifies the differential ECG signal while decreasing the noise.</p>
<p>It's the instrumentation amplifier. The instrumentation amplifier, is an amplifier that is particularly built for measurement. This will be measuring your heart rate. The other amplifier (operational amplifier) is to amplify the signal that the heart rate is giving off. The signal is so small that it needs to be larger in order for it to be read and later displayed on the LCD.</p>
<p>what is the purpose of 10nf capacitor? why is it placed in between the output and low pass filter? does 30hz cut off frequency too big for ecg signal from the body? why not make the cut off 10 or lower which is close to heart's frequncy (1-4 hz)? Im sorry if I have a lot of question, just trying to understand the circuit before making it. :P</p>
<p>the 10nf capacitor is used to cut pure DC from the signal. You can add a resistor to make a high-pass filter with a really low cutoff frequency (&lt;1Hz) instead, it'll work better.<br>I chose 30Hz for cutoff because I wanted a good time resolution for my signal, and even this is a bit low. If you put the cutoff too low the signal will become strongly distorted, it might still work for finding the heart rate but the characteristic ecg signal features will be removed from the signal by your filter. I suggest you read a bit about Fourrier math if the topic interests you. ECG signal is not a sine wave at 1-4Hz, it's a mix of an infinite number of sine waves of all frequencies with different amplitudes, when you put a filter to remove specific frequencies you alter the temporal shape of the signal, because time and frequency are Fourrier pairs. </p>
<p>Hi, how are you?, I have one question about the circuit if you can help me, my questions is why you need the regulator (7805)? and what is the output of 7805?</p>
<p>to make a negative voltage rail (-5V) to supply the op-amps.</p>
<p>hii bro, my circuit is not working.. i hope you can reply me and suggest me please..</p><p>i do everything in the tutorial but didn't work, and the lcd alsways print &lt;30 bpm.</p><p>1. i want to know where input to the ground v+ or v- ?</p><p>2. where the output?</p><p>thanks bro..</p>
<p>1. The ground is 0V, V+ is 5V and V- is -5V. In the Ina128, the input of the ground is on pin 5, or &quot;Ref&quot;</p><p>2. The output is just before the op-amp input, after the filter section.</p>
<p>hii... i tried that 2 electrodes on fingers and its working(getting waveform)...but 1 problem is that it doesnt have a stable base line..what i mean is that the baseline keeps shifting up and down....so how will i calculate heart rate(i was planning to set some threshold)</p><p>and another major problem...for heart rate i am passing it through op-amp and taking output after diode..but getting 0 as soon as i feed my output to op-amp... if op-amp is not connected and output taken after the filter, than i am getting waveform.. but as soon as op-amp is connected the output goes to 0...what could cause that?? thanks in advance!</p>
<p>Base line shift may be due to unwanted electrode motion, make sure you stay still. You can add a high-pass filter with a very low cutoff frequency (&lt;1Hz) to remove this artefact and provide a stable baseline.</p><p>You should check your connections to your op-amp, it looks like it shorts something when you plug it, check the pinout carefully and if you can test only this section with a signal generator and scope you'll be able to troubleshoot quickly.</p>
<p>hii.. ı dont understand the pin connection of 7805 (voltage regulator) because circuit is complex. I used to arduino's 5V but ina128 is very heat. what is our purpose while 7805 is using ? are you writing 7805 's pin connection and ina128 4. pin ? thanks in advance...</p>
<p>Yes, overheating of 7805 is a common issue here, probably it's because you wired it backwards like many others. I hope you've reacted quickly by removing power before permanent damage was done to some components. The most dangerous thing for your safety here is the 9V battery short-circuit, as it may explode if the short draws too much current, I've never seen that but it can happen. So now remove the 7805 of the circuit, check if it's still working &amp; check if your battery still have some juice. If you can't get 5V out of it, you unfortunately burned it and need a replacement (we all learn that way one day or another, don't worry about it, it happens to everybody ;) Maybe I should use a 7905 in this instructable to make sure this common mistake will no more harm anybody... but when I was building this I only had 7805 on hand, so I made a little trick not so easily understandable for beginners : making a negative voltage supply with a positive voltage regulator. So, for example, if you had a 5V battery, how would you make -5V? By putting the plus lead to the circuit ground, and the minus lead would give you -5V. It's the same thing here, excepted that you're using a positive voltage regulator, so you need to use the correct polarity in the input section (+ lead of 9V goes to input+, - lead of 9V goes to &quot;GND&quot; of the regulator, but you reverse the output section without connecting the regulator ground to the circuit ground, so the regulator output goes to circuit ground, and then the regulator ground becomes -5V relative to the circuit ground, perfect for the negative supply of op-amps. Almost no current is drawn by this line, so it really shouldn't heat. Ho and also, the bottom &quot;positive&quot; strip of the breadboard is not positive at all, it's supposed to be -5V in fact, if you look at the schematic it goes only to V- of op-amps. It's not a perfect design in an engineering point of view, but I consider myself more like an hacker, so it's not beautiful but it works hahaha!</p>
<p><a href="http://www.instructables.com/member/birdyberth/" rel="nofollow">Birdyberth</a>. Great project! Can you tell me your process to finding a heart beat. My circuit works, but when I add the electrodes the LED doesn't correspond and the oscilloscope can't read a beat.</p>
<p>I am a student trying to learn electrical engineering. I am plugging my circuit and electrodes into the scope and I am only recieving static.Has anyone found a good place for the electrodes?</p>
<p>I have to filter the signal yet, but this is satisfactory as well :)</p>
<p>I don't see the familiar wave shape of an heart beat out there... However you seem to have put the two electrodes on the same wrist. Try putting one electrode on each wrist (one on your right and the other on your left). Also, a good ground is important, I don't know if you had grounded yourself to the circuit but you should, it really helps to get rid of the noise. If every electrode is well placed, you should be able to observe the heart signal with a small amount of noise, the filter is there to extract residual noise but the most part of the job is done by the instrumentation amplifier itself.</p>
hi<br>i have a couple of cuestions, does de code needs any modification?, what ecg model are you using for this project.
<p>My code does only very basic amplitude peak detection it's the simplest model ever. To use an ecg model for a more accurate computing, you'd need to sample the signal with an ADC, something this project isn't doing (but I'm working on something similar right now).</p>
Thank you for replying my previous comment☺️. I have another ques. <br>1) the speaker wire has polarity positive and negative. So, if i were to put 2 inputs like you (2 electrodes ) do i need to connect all the input to the positive speaker wire and the negative should be put to ground? Im confused. <br><br>2) at which pin of ina128 i should put the three inputs(including antistatic wrist strap) ? In your schematic diagram, i need to put the input probes at the Vin- and Vin+ .. So , is it the electrodes connect to Vin+ and the antistatic wrist strap connect to Vin-? Or it doesnt matter?
<p>My pleasure, don't hesitate to ask more question if something isn't clear!<br>1) speaker wire doesn't have a polarity, it's a wire, you can connect it the way you want! :) In this project I use it to connect my two electrodes to the Vin+ and Vin- inputs of the instrumentation amplifier.<br>2) The two chest electrodes go to Vin+ and Vin- and the antistatic wrist strap is connected to the ground. <strong>Vin- isn't the ground</strong></p>
And can i know, which part is the output for ecg? I mean at which part of the IA or Opamp i should insert the output cable?
<p>After the Instrumentation amplifier.</p>
Hi . Can we use jumper wire instead of speaker wire?

About This Instructable

172,887views

608favorites

License:

More by birdyberth:3D Contactless Mouse (Interactive 3D Position Sensor) Electrocardiograph & Heart Rate Monitor 
Add instructable to: