# Creating a table of sensor data from arduino?

**URL:** <https://discourse.processing.org/t/creating-a-table-of-sensor-data-from-arduino/7942>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [January 29, 2019, 7:51pm UTC](https://discourse.processing.org/t/creating-a-table-of-sensor-data-from-arduino/7942 "2019-01-29T19:51:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dab](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dab](https://discourse.processing.org/u/Dab)\
**Post date:** [January 29, 2019, 7:51pm UTC](https://discourse.processing.org/t/creating-a-table-of-sensor-data-from-arduino/7942/1 "2019-01-29T19:51:09Z")

</div>

Hi there, im pretty new to the processing application, so bear with my knowledge.  
Ive got a mpu6050 reading out yaw ptich roll angles on the serial monitor on aurdino IDE, but i want to save the output to a .csv file. im using “,” to split the values. im also using table() to create a table and add the values split by “’,” to its own colum. The file is not being created?

code below:

```auto
import processing.serial.*;
Table table;
String val;
Serial myPort;
void setup()
{
String portName = "COM3";
myPort = new Serial(this, portName, 115200);
table = new Table();
table.addColumn("id");
table.addColumn("sensor1");
table.addColumn("sensor2");
table.addColumn("sensor3");
}

void serialEvent(Serial myPort){
val = myPort.readStringUntil('\n');
val = trim(val);
println(val);
float sensorVals[] = float(split(val, ','));

TableRow newRow = table.addRow();
newRow.setInt("id", table.lastRowIndex());
newRow.setFloat("sensor1", sensorVals[0]);
newRow.setFloat("sensor2", sensorVals[1]);
newRow.setFloat("sensor3", sensorVals[2]);

saveTable(table, "data/new.csv");
}
void draw()
{
//visualize your sensor data in real time here! In the future we hope to add some cool and useful graphic displays that can be tuned to different ranges of values.
}

```

arduino serial output:

![Screenshot_1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a9d6d560908e33eeb53afdef9f1cc042f91d230c.png)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [January 30, 2019, 5:26am UTC](https://discourse.processing.org/t/creating-a-table-of-sensor-data-from-arduino/7942/2 "2019-01-30T05:26:30Z")

</div>

I tested your code using the code below and it worked. Are you sure you are receiving the data in your sketch? A quick test is to add `println()` in your code to check those values been saved. Another suggestion is to use `serial.list()[?]` where ? should be replaced with the com port you want to connect to.

Also, make sure the arduino is not talking to the serial monitor while you are trying to connect to your arduino unit.

Kf

```java
Table table;

void setup() {

  table = new Table();  
  table.addColumn("id");
  table.addColumn("species");
  table.addColumn("name");

  frameRate(5);
}

void draw() {

  println("Current frameRate ", frameCount);

  if (frameCount==20) exit();

  TableRow newRow = table.addRow();
  newRow.setInt("id", table.getRowCount() - 1);
  newRow.setString("species", "Panthera leo");
  newRow.setString("name", "Lion");

  saveTable(table, "data/new.csv");
}

```

---

<div class="post-metadata">

**Author:** ![Dab](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dab](https://discourse.processing.org/u/Dab)\
**Post date:** [January 30, 2019, 3:31pm UTC](https://discourse.processing.org/t/creating-a-table-of-sensor-data-from-arduino/7942/3 "2019-01-30T15:31:57Z")

</div>

Thanks for the help @kfrajer i’ve managed to get it saving to a csv file 😄
