HOW TO EXPORT DATA from ARDUINO SERIAL MONITOR to a CSV or TXT FILE

Hello,

Does anyone know how I can export information displayed on my serial monitor into a csv or txt file? I have heard there is a way to do this through processing but I don't know how.
Any suggestions are more than welcome!

The simplest way would be to use a program such as puTTY in place of the Arduino Serial Monitor. puTTY can save data into a file.

You could also write a program on your PC to receive the data and save it into a file. This Python - Arduino demo should provide some ideas - it would need to be extended a little to save the data into a file.

You could do the same sort of thing with Processing (which I don't know) or using your preferred PC programming language.

...R

1 Like

Hi again,

I found a code through which I can transfer data from Arduino to Processing.

I also made modifications to the file name and the value measured as well, I run the processing code but I only get a .txt file, which remains empty.
I only got a file with values once at the very beginning, when I was still experimenting with running the code, so I don't really know how the values where included at the file then but not now.

The only thing I have noticed as far as now is that I can't run the serial monitor in Arduino at the same time when processing is running as well, meaning I have to run them separately so that there is no port clushing (I got this kind of error at the beginning).

Any suggestions?

sketch_151227b_Arduino_to_Processing.pde (536 Bytes)

Arduino_DustSensor_servo.ino (2.84 KB)

1 Like

There is no need to attach code when the code is so short.

//From Arduino to Processing to Txt or cvs etc.
//import
import processing.serial.*;
//declare
PrintWriter output;
Serial udSerial;

void setup() {
  udSerial = new Serial(this, Serial.list()[0], 9600);
  output = createWriter ("dust_concentration.txt");
}

  void draw() {
    if (udSerial.available() > 0) {
      String SenVal = udSerial.readString();
      if (SenVal != null) {
        output.println(SenVal);
      }
    }
  }

  void keyPressed(){
    output.flush();
    output.close();
    exit(); 
  }

Since you name the file with a txt extension, you can hardly expect the file to magically acquire a csv extension.

Are you absolutely certain that the Arduino is connected to the first com port in the list?

I don't see the Arduino sending any comma separated values. EVERYTHING that it sends should be being recorded in the txt file, IF the Arduino is on the COM port that Processing is listening to. Clearly, you don;t want all that crap recorded in the file.

you may use Putty:

  1. install putty:
    sudo apt-get install putty putty-tools

  2. run Putty. It should be inside the internet apps (I don't know why)

  1. in Putty select serial and specify the right port:
  1. then on the left under session go to the logging. select the printable output. and then specify the right address and file name for the output file:

then everything in the terminal will be recorded to the file. I hope it helps.

1 Like

You are a saver !!! Worked Perfectly!!! Really thank you man!!! :slight_smile: :slight_smile:

foadsf:
you may use Putty:

  1. install putty:
    sudo apt-get install putty putty-tools

  2. run Putty. It should be inside the internet apps (I don't know why)

Imgur: The magic of the Internet

  1. in Putty select serial and specify the right port:

Imgur: The magic of the Internet

  1. then on the left under session go to the logging. select the printable output. and then specify the right address and file name for the output file:

Imgur: The magic of the Internet

then everything in the terminal will be recorded to the file. I hope it helps.

Why were you not pleased with reply #1 but so very pleased with reply #4?

Was it because you didn’t understand the first reply? If so why did you not ask about the bits you didn’t understand.