Arduino ECG sputtering out totally random values

arduinobiopotentialbluetoothc

I have encountered a problem in my ECG/EKG design.

I am trying to make an ECG using an Arduino as a microcontroller to send/retrieve heart rate measurements via Bluetooth (JY-MCU.)

I know my circuit is working because when I place an LED in op-amp output and its ground, I get a slight dimming of the light if I gently put my hand on the leads. I know the issue is with my code. I have been working on this project for a while and still can't find a solution.

Here is my schematic:

enter image description here

Here is my code that I think is incorrect. The code is just the bare minimum.

// External variables
const int  signal = 8;    // Pin connected to the filtered signal from the circuit
unsigned long time;   
unsigned long frequency;
char freq[3];

// Internal variables
double period = 2000;
double starttime = 2000;
double input = 0;
double lastinput = 0;
unsigned long death = 0;

// initialize the library with the numbers of the interface pins

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

void loop() {
delay(500);

time = millis();
input = digitalRead(signal);

 period = time - starttime; // Compute the time between the previous beat and the one that has just been detected
 starttime = time; // Define the new time reference for the next period computing
 death = time;
 frequency = 60000/period;
 freq[0] = frequency/100+48; // Sort the hundreds character and convert it in ASCII
 freq[1] = (frequency/10)%10+48; // Sort the thents character and convert it in ASCII
 freq[2] = frequency%10+48; // Sort the units character and convert it in ASCII
 Serial.println(freq);
}

All I'm getting is either 120 or 119 as my value. It fluctuates between those two. I tried changing my resistors out but that didn't do anything. I also completely took the wire between pin 8 and the breadboard out, and it still fluctuated between 119 to 120. I don't have any idea what is going on here! I would appreciate it if someone could help me out here.

Best Answer

That amplifier will simply not give you an ECG signal. There's nowhere near enough gain, and the common mode rejection is very bad. You need to get a grip on your data acquisition using some sort of test signal that you can use without your amplifier. After you get that working, then you can work on a working amplifier. You'll get nowhere fast trying to work on every aspect of your problem at the same time.

Looking at your code, you seem to be calculating the time between your SAMPLES (which is why you're getting something near constant), which has nothing to do with heart rate. Somehow, you need to process a VALID ECG signal to yield heartrate.