Detecting heart beat with ECG module AD8232?

Hi,

I am using AD8232 sensor to detect ECG.

I am using Arduino Nano, AD8232 is connected to 3.3V and wiring is:

(AD8232 pin - Adruino Nano pin)

  • GND - GND
  • 3.3V - 5V
  • OUTPUT - A2
  • LO- - D11
  • LO+ - D10
  • SDN - not connected

I am using this code:

int Signal; // holds the incoming raw data. Signal value can range from 0-1024

void setup() {
  pinMode(10,INPUT);
  pinMode(11,INPUT);
  
  Serial.begin(9600);
}

void loop() {

  if ((digitalRead(10)==1)||(digitalRead(11)==1)) {
    Signal = "";  // no data
  }
  else {
    Signal = analogRead(A2);
  }

  Serial.println(Signal);  // print data

  delay(1);  //Wait for a bit to keep serial data from saturating
}

Now, this works just fine, I get a series of numbers, which I can draw (could be done even with LibreOffice Calc/Excel) and get ECG "line".

But I would also like to detect heart beat and compute bpm (bets per minute). How to do that?

One option would of course be to introduce a variable called Threshold - if Signal is higher than Treshold, then beat would be detected. In fact, I have found a code, where Treshold has been set to 550. But in my testing Signal has never been over 550. Also, top value of a Signal in R-wave is not always the same...

Another option would be, to detect maximum value, but how to avoid detecting local maximum (PR interval and QT interval)?

I mean, there is also a problem, that someone would not have "ideal" ECG curve, how to detect heart beat in that case?

P. S. What is SDN pin on module?

  • GND - GND
  • 3.3V - 5V

I guess the sensor won't like to much. The datasheet says the absolute maximum voltage is 3.6V and you connect it to 5V?

Uh, sorry, my stupid mistake. I connected it to 3.3V, I don't know how I wrote 5V.

So sorry, again. Sensor is connected to 3.3V and NOT 5V.

i am having a same doubt, how can i calculate heart rate from the ecg graph except using a threshold value concept.