AD8232 ecg sensor incorrect waveform

I am using AD8232 ecg sensor with Arduino uno.

Connected the sensor with Arduino uno exactly like this:


The code I have used

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);
}

Values on Serial Monitor:

Waveform on Serial Plotter:

I have purchased the sensor from here

Things I maintained:

  • Removed laptop charger while arduino board is connected through USB
  • Tried not to move too much while taking a measurement
  • Tried both fresh and used pads but the result is same
  • Stuck the pads on dry and clean area of skin
  • Tried the sensor placement on different individuals (one except me)
  • Tried both arm-leg and chest placement

Also placed the green one on right leg

Now please help me to find out what is the problem as I am not getting ecg waveform accurate. I have seen severatal youtube tutorials following the same procedure but getting the accurate ecg graph. How to solve the issue?

Please tell us what you think is wrong!

The waveform I got, isn't the accurate ecg graph

You said as much. What is different from what you are expecting?

The actual ecg graph look like this:

but mine is:


Though I have done all the steps correctly

See the flat top on some of the signals and high amplitude on some others? That is telling you that the gain/amplification is set too high. Check your equipment adjustments.

The graph shows a total variation of just 3 points, from 336 to 338. That is simply random noise, not a signal at all.

There is no signal being input to the ADC, so redo the wiring, making sure that connections are cleanly soldered. If that doesn't help, suspect a nonfunctional sensor.

I changed the wiring several times and soldered the sensor to the header pin and connected to the breadboard. But that didn't work.

It looks as though your AD8232 is not giving the correct output.
However I see another issue, to do with the resolution of the Serial Plotter.

You are using version 2.x.x of the IDE.
In that version, the Serial Plotter only plots 50 points.

I much prefer to use the Serial Plotter of IDE version 1.x.x, which plots 500 points.

I don't have an AD8232, but have used a Function/Arbitrary Waveform Generator to provide a simulated ecg signal to illustrate the problem.

Using a 1.333Hz signal to represent a pulse of 80 b.p.m, in IDE 1.8.19 the waveform is acceptable, and looks like:

But look at what the same signal looks like using the Serial Plotter in IDE 2.3.6, with only 50 points plotted:


You only see a fraction of one pulse beat, and it is not even obvious which part it is.

An improvement can be made by changing the delay(1) in your code to delay(50), but the resolution is still no where near as good as it was using IDE 1.8.19:

It might be worthwhile changing delay(1) to delay(50), to see if you are getting a good signal from your AD8232.

Thanks for your suggestion. I have adjusted it to 500 points on x-axis from IDE settings but the y-axis is auto scaled. How to solve this?

I am a beginner in the area. Could you please suggest me any resources from where I can learn.

You can stop the auto scaling by printing an upper and a lower limit along with your ecg data.

Choose values for upperLimit and lowerLimit and define them before setup( ), for example:

int upperLimit = 900;
int lowerLimit = 100;

Then change what you print in loop( ) to:

    Serial.print(upperLimit);
    Serial.print(", ");
    Serial.print(lowerLimit);
    Serial.print(", ");
    Serial.println(analogRead(A0));

This will print two additional straight limit lines, that will stop the y-axis autoscaling:

How did you manage that?
I didn't know that it could be changed in the settings.

I have set "U=Object(o.useState)(50)" to "U=Object(o.useState)(500)" from “C:\Users\ your_username \AppData\Local\Programs\Arduino IDE\resources\app\lib\backend\resources\arduino-serial-plotter-webapp\static\js\ main.hash_value.chunk.js ” to get 500 points plots instead of 50 on serial plotter horizontally.

Now the graph looks like this with a lower and upper limit. This time I have tried it with Arduino IDE 1.8.19. Still it's not an accurate ecg graph. Could you please share any materials or something else, from which I can find out the solution on how I can get a actual ecg graph

As before, the graph is just random noise.

Post a close up, focused picture of your wiring, showing details of the solder connections.

First I recommend to measure the continuity of ECG leads between electrode pad connector and 3,5 mm plug. If all tree lead are ok, plug the 3,5 mm plug in to heart monitor module and measure again. If continuity is still ok, might the electrode pads be non conductive and outdated. If no conductivity be sure to check that the 3,5 mm plug is firmly pressed to the end of the heart monitor module connector.

3,5 mm plug not fully inserted.

3,5 mm connector properly inserted.

I measured the continuity of my own ECG leads:
Electrode pad connector 3,5 mm plug AD8232 Heart monitor module
Red (marking R) -> base -> RA
Green (marking F) -> middle -> LA
Yellow (marking L) -> tip -> RL

As you can see the markings on the pad connector and heart monitor module have not all the same meaning.

AD8232 Heart Rate Monitor Github page: GitHub - sparkfun/AD8232_Heart_Rate_Monitor: AD8232 Heart Rate Monitor



I removed the jack or plugged in, the serial plotter and monitor shows the same result


Nothing but a tiny bit of noise.

Use your multimeter to check whether the sensor board itself output any change in signal, as you touch or move around the body contacts.

It is hard to tell from your photo but the GND on the AD8232 looks like it has a solder blob on it which may not be a good electrical connection. The 3.3V pin might have the same problem. Try to make sure that those connections are good.

The other thing is it looks like you have also soldered header pins in the RA, LA and RL positions on the board. If so, the breadboard will short all three together which might explain why you aren't getting a signal.

Pete

Good catch. That is exactly the problem. As you can see from the schematic below, that shorts together all the body electrode connections.

REMOVE that 3 pin header!

As shown in this example (right hand side of photo):