serial monitor to text file

Hello, I was wondering if there was an easy way to output the results in the serial monitor to a text file?
Seems like there should be an easy way of doing that..

thanks for the help and sorry if its been asked before. didn't come up in a search.

This is what I do: I receive data coming from Arduino into Hyperterminal. When finished, I copy/past the received data into notepad and save it for later use.

hej,

a little bit more fancy way would be to write a small little program in processing which receive all the data from the serial port and print it to a text file,
if you want i can pass the code to you, but on the other hand it is really easy, you know the processing GUI is the same as for Ardunio,

ha det bra
tomek

test

I haven't actually tried this, but you should be able to pipe input from a serial port directly to a file by typing something like

COPY COM1 filename.txt

at the "DOS" command line. A Ctrl-Z (hex character 0x1A, ASCII 26) coming in will close the file.

See http://chrio.org/serial/ for ideas.

If you use hyperterminal then it is easy to save any incoming serial data. Just connect to your Arduino, and then go to the 'Transfer->Capture Text' menu option. Select a file to save your data and away you go! All incoming serial data will then be automatically saved for you.

Probably illegal but in fedora linux at 9600 baud for standard ascii characters:

tail -f /dev/ttyUSB0 > myfile

to append

tail -f /dev/ttyUSB0 >> myfile

To watch it in another terminal do

tail -f myfile

:wink:

If they're not standard covert them to decimal or something. You can even output data to a cvs format if you're a bit creative.

1 Like

Hi,

Can anyone send me program code to save serial port data in text file format please?

Yashar

If you are on a Windows system, GoBetwino can do that:

If you have python installed a small script does the job. Below a capture-script for an Arduino generated csv file.

Python - http://www.python.org/ -
Serial Lib - http://pyserial.sourceforge.net/ -

import sys, os, serial, threading

def monitor():

    ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)

    while (1):
        line = ser.readline()
        if (line != ""):
            #print line[:-1]         # strip \n
            fields = line[:-1].split('; ');

            // ID = fields[0]
                  // TIME = int(fields[1])
            # print fields
            print "device ID: ", ID
            # write to file
            text_file = open("Pdata.log", "w")
            line = str(TIME) + ": " + str(CT) + "\n"
            text_file.write(line)
            text_file.close()

        # do some other things here

    print "Stop Monitoring"

""" -------------------------------------------
MAIN APPLICATION
"""  

print "Start Serial Monitor"
print

COMPORT = 4;
BAUDRATE = 115200

monitor()