TL;DR
I can read out my heart rate but I have to physically touch GND of the Arduino or else the signal is just noise.
Description
So I've started to play around with an Arduino and wanted to try out a heartrate sensor module (AD8232).
The following is the code I am using for this:
const int CONNECTED_LED = 13;
const int LO_MINUS = 10;
const int LO_PLUS = 11;
bool disconnected = true;
enum State {
CONNECTED,
DISCONNECTED,
LO_MINUS_DISCONNECTED,
LO_PLUS_DISCONNECTED
};
enum State currentState = DISCONNECTED;
void setup() {
Serial.begin(9600);
pinMode(LO_MINUS, INPUT); // Setup for leads off detection LO +
pinMode(LO_PLUS, INPUT); // Setup for leads off detection LO -
}
void loop() {
State nextState = getState();
if (nextState != currentState) {
// Store the current state
currentState = nextState;
switch (nextState) {
case DISCONNECTED:
break;
case LO_MINUS_DISCONNECTED:
break;
case LO_PLUS_DISCONNECTED:
break;
}
}
if (currentState == CONNECTED) {
digitalWrite(CONNECTED_LED, HIGH);
Serial.println(analogRead(A0));
} else {
digitalWrite(CONNECTED_LED, LOW);
// Serial.println(-1);
}
delay(1);
}
State getState() {
if (digitalRead(LO_MINUS) == 1 && digitalRead(LO_PLUS) == 1) {
return DISCONNECTED;
} else if (digitalRead(LO_PLUS) == 1) {
return LO_PLUS_DISCONNECTED;
} else if (digitalRead(LO_MINUS) == 1) {
return LO_MINUS_DISCONNECTED;
}
return CONNECTED;
}
This is how I am connecting the boards (I double checked already twice)
AD8232 | Arduino UNO R3
------------------------
GND | GND
3.3v | 3.3V
OUTPUT | A0
LD- | ~10
LD+ | ~11
SDN | <not used>
I've followed this diagram for connecting the electrodes:
However, the result is a random signal unless I am touching the USB-connector or GND of the Arduino.
Below you can see the random signal and the moment I touched the connector. I noticed this by accident after hitting the reset button after wondering why on earth I only get this random signal:
So.. what's going on here? I have all three electrodes connected.
I've even tried to different modules (I bought the AD8232 two times) but I see the same issues with both modules.
If I touch something else e.g. a radiator (heater) then the signal becomes another kind of random. It only works touching the connector.
Since this appears like a grounding issue I checked for continuity from the GND pin of the AR8232 to the USB connector and continuity is given.
I'm not expert enough (yet) to see the problem. Anybody?
A0
. It's just that it does not resemple a heartbeat ECG at all.