Can't get ECG data - Arduino

Hello Karu community,

For the past couple of weeks, I haven't been able to find a solution to my problem. My problem is that I cannot get data from my home ECG which I created from Arduino. I'm an absolute amateur at this, but I'm sure it's a circuit design problem. This is what my circuit looks like now. (Note: "Dual O" in the lower left corner) is an instrumentation amplifier, not an operational amplifier like the one in the middle.

1

Here is my code:

const int  signal = 5;    // Pin connected to the filtered signal from the circuit
unsigned long currentBeatTime;   
unsigned long previousBeatTime;

unsigned long frequency;

// Internal variables
unsigned long period = 0;
int input = 0;
int lastinput = 0;


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

previousBeatTime = millis();
}

void loop() {
delay(500);
input = digitalRead(signal);

if ((input != lastinput) && (input == HIGH)) {
    // If the pin state has just changed from low to high (edge detector)
    currentBeatTime = millis();

    period = currentBeatTime - previousBeatTime; // Compute the time between the previous beat and the one that has just been detected
    previousBeatTime = currentBeatTime; // Define the new time reference for the next period computing
}

lastinput = input; // Save the current pin state for comparison at the next loop iteration

// Detect if there is no beat after more than 2 seconds
if ( (millis() - previousBeatTime) > 2000 ) 
{ 
    Serial.println("dead");
}
else 
{
    if (period <= 0) 
    {
        frequency = 0;
    }
    else 
    {
        frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds
    }

    Serial.print(frequency);
    Serial.println(" : alive! ");
}
}

      

I would be grateful if someone can answer me as soon as possible. Thank!

+3


source to share


1 answer


You seem to be reading the voltage on pin 5 after the current has passed through the LED. LEDs produce a voltage drop, so it is possible that the voltage will never be high enough to register as high on a digitalRead () call. You may have changed where you sample the voltage, or try using analogRead ().



In any case, you need to establish that this is a programming problem that will be hosted on this board. Perhaps electronics.stackexchange will provide better help.

0


source







All Articles