Single lead means it has 3 connecting leads. The traditional ECG machines have 6 leads. Computerized ECGs have 12 leads. Patient monitors inside OT/OR often have one lead. The Arduino based patient monitor board we discussed before is costly and actually never became hugely popular. The module can extract, amplify, and filter small biopotential signals. ECG is the recording of the electrical activity generated by heart muscle depolarizations, which are propagated as pulsating electrical waves towards the skin.
Can ECG from AD8232 detect disease? Your expectation is too much. With common codes and hardware, you’ll get too much noise. You’ll understand an ECG curve and get the heart rate. The heart rate count is near perfect.
This kind of ECG used for monitoring under anaesthesia patients who are not known to have an electrical problem of the heart. Basically calibrated machines required for medical grade works. No way AD8232 can be discouraged from casual experiments. There is nothing wrong to watch curves by AD8232 on an already diagnosed patient. Professional single channel ECG machines cost near $300.
---
SparkFun probably introduced AD8232 first. It is open hardware and there are clones. These days price including the leads is around $12. Probably not shields are exactly the same.
Another way to see the output is using 2 channel oscilloscope. We talked about DIY oscilloscope kits. It is good to read add-on :
1 | http://www.joshluben.com/blog/sparkfun-heart-rate-monitor/ |
The electrodes which are supplied are for once usage – disposable. Their performance deteriorates with time. 3M manufactures disposable electrodes. Here is datasheet of AD8232 :
1 | https://www.analog.com/media/en/technical-documentation/data-sheets/ad8232.pdf |
Common connection for the module with Arduino is :
GND to GND
3.3v to 3.3v
OUTPUT to A0
LO- to digital pin 11 (LO- = Leads-off Detect-)
LO+ to digital pin 10 (LO+ = Leads-off Detect+)
SDN -Not used (SDN = Shutdown)
Now about sensor pad placement. Snap the sensor pads on the leads before applying to the body. Black will sit on RA (Right Arm), Blue will sit on LA (Left Arm), Red will sit on RL (Right Leg). You should web search see illustration to check placements.
You’ll upload the sketches via Processing software version 2.2.1 to monitor the serial output. Later versions may not work as intended. This is the first test code to test from Arduino IDE :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | int loPin = 11 int lnPin = 12 int ECGout = A0 void setup() { // initialize the serial communication: Serial.begin(9600); pinMode(loPin, INPUT); // Setup for leads off detection LO + pinMode(lnPin, INPUT); // Setup for leads off detection LO – } void loop() { if((digitalRead(loPin) == 1)||(digitalRead(lnPin) == 1)) { Serial.println(‘!’); } else { // send the value of analog input 0: Serial.println(analogRead(ECGout)); } //Wait for a bit to keep serial data from saturating delay(5); } |
This will give graphical ECG waveform, this is for uploading via Processing IDE :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | import processing.serial.*; Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph float height_old = 0; float height_new = 0; float inByte = 0; void setup () { // set the window size: size(900, 400); // List all the available serial ports println(Serial.list()); // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[1], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); // set inital background: background(0xff); } void draw () { // everything happens in the serialEvent() } void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n'); if (inString != null) { // trim off any whitespace: inString = trim(inString); // If leads off detection is true notify with blue line if (inString.equals("!")) { stroke(0, 0, 0xff); //Set stroke to blue ( R, G, B) inByte = 512; // middle of the ADC range (Flat Line) } // If the data is good let it through else { stroke(0xff, 0, 0); //Set stroke to red ( R, G, B) inByte = float(inString); } //Map and draw the line for new data point inByte = map(inByte, 0, 1023, 0, height); height_new = height - inByte; line(xPos - 1, height_old, xPos, height_new); height_old = height_new; // at the edge of the screen, go back to the beginning: if (xPos >= width) { xPos = 0; background(0xff); } else { // increment the horizontal position: xPos++; } } } |
If the sketch does not work, modify the following line:
1 | myPort = new Serial(this, Serial.list()[1], 9600); |
This is exactly from SparkFun :
The user need to change the parameter inside Serial.list()[N]. A List of available COM ports will appear in the lower portion of the sketch window. Remember that COM port selection begins at 0.Typically your Arduino will appear as the highest COM number if it is the only device connected to your computer.
if the processing sketch is giving you issues, check this part of the code:
1 | comPort = new Serial(this, Serial.list()[2], 9600); |
This is for Arduino IDE (look at it’s serial plotter) :
1 2 3 4 5 6 7 8 9 10 11 12 | const int heartPin = A0; void setup() { Serial.begin(115200); } void loop() { int heartValue = analogRead(heartPin); Serial.println(heartValue); delay(5); } |
There is enough serious work like this project :
1 | https://www.instructables.com/id/DIY-ECG-EKG-Portable-Heart-Monitor/ |
Pi actually can utilize the module better. HealthyPi expansion card is big-budget thing.
Tagged With ecg module ad8232 , ad8232 arduino , arduino ecg module , ad8232 ecg module explanation , arduino ekg ad8232 , ad8232 processing , ad8232 ekg windows , AD8232 ECG Sensor , ad8232 ecg , single lead ecg arduino