Save Meassurement Data with processing to excel

edited June 2016 in Arduino

Hi Guys, I want to save meassurement datas from my arduino Nano with processing in an excel file. To test my code I programmed the arduino to print the integer number 20 every 100msec to the serial monitor.

This is my processing code:

import processing.serial.*;
Serial myPort;

Table table;

int val;
int numReadings = 10; 
int readingCounter = 0;

void setup() {
 String portName = Serial.list()[0];
 myPort = new Serial(this, portName, 9600);

  table = new Table();

  table.addColumn("id");
  table.addColumn("minute");
  table.addColumn("second");
  table.addColumn("wert");


}

void draw() {

  val = myPort.read();
  println(val);

      TableRow newRow = table.addRow();
  newRow.setInt("id", table.lastRowIndex());
  newRow.setInt("minute", minute());
  newRow.setInt("second",second());
  newRow.setInt("wert", val);

  readingCounter++;

 if (readingCounter % numReadings ==0)
 {
   saveTable(table, "data/new8.csv");
 }
}

it should simply print: number of table row, minute, second, 20

but it prints:

88,37,58,50

89,37,58,48

90,37,58,13

91,37,58,10

92,37,58,-1

93,37,58,-1

94,37,58,50

95,37,58,48

96,37,58,13

97,37,58,10

98,37,58,-1

99,37,58,-1 and so on...

why does it show 50 then 48 then 13 then 10 and then two times -1? And how can I convert that to the original integer number 20?

I tried this:

 val = myPort.readString();
 newRow.setString("wert", val);

but then the value 20 is only in the last row of the excel file. In all other rows only row id, minute and seconds are printed. Like this:

82,8,58,

83,8,58,

84,8,58,

85,8,59,

86,8,59,

87,8,59,"20

Sign In or Register to comment.