Pages: [1]   Go Down
Author Topic: serial monitor to text file  (Read 8996 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Netherlands
Offline Offline
Sr. Member
****
Karma: 0
Posts: 414
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

malmö / berlin
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
fhp>--vs--<k3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

test
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Greenwood, Indiana
Offline Offline
God Member
*****
Karma: 0
Posts: 508
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

smiley-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.
Logged

If it was designed by man it can be repaired by man.

Sydney
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

Yashar
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.mikmo.dk/gobetwino.html
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 223
Posts: 13896
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/ -

Code:
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()
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: