Writing the ECG Data to Excel File


I am using AD8232 ECG frontend to capture the heartbeat using Arduino UNO and Processing 2.2.1.

This is the code i am using in Arduino IDE:

void setup() { // initialize the serial communication: Serial.begin(9600); pinMode(10, INPUT); // Setup for leads off detection LO + pinMode(11, INPUT); // Setup for leads off detection LO -


void loop() {

if((digitalRead(10) == 1)||(digitalRead(11) == 1)){ Serial.println('!'); } else{ // send the value of analog input 0: Serial.println(analogRead(A0)); } //Wait for a bit to keep serial data from saturating delay(1); }

and this is the code i am using in sketch to view the waveform:

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(1000, 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()[0], 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++; }

} }

But the generated graph doesn't have any data values on x and y axes. Also i want to store this data in an excel file. How can i do it ?

First: Please read the sticky post at the top of the topic about how to post in this forum. Then edit your post and add code tags!

Please post a wiring diagram of your setup. If the wiring is not correct you cannot see any value in the graph. I guess you don't use the sensor directly but by some breakout board. Post a link to that board!