Go Down

Topic: HOW TO EXPORT DATA from ARDUINO SERIAL MONITOR to a CSV or TXT FILE (Read 44583 times) previous topic - next topic

Nicon

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!

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

Nicon

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?



PaulS

There is no need to attach code when the code is so short.
Code: [Select]
//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.
The art of getting good answers lies in asking good questions.

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)

http://imgur.com/a/Dx695

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

http://imgur.com/a/ecNqn

4. 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:

http://imgur.com/a/OLL7q




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


s_vasilis

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

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)

http://imgur.com/a/Dx695

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

http://imgur.com/a/ecNqn

4. 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:

http://imgur.com/a/OLL7q




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



Grumpy_Mike

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.

Go Up