Go Down

Topic: Serial to file? (Read 3512 times) previous topic - next topic

Godge

Does anyone have any suggestions for an application that can log serial inputs to file?  For linux or windows, I don't mind.

I've got my arduino reading temperatures and printing them to the serial monitor - now I just want to be able to log these readings to file so I can report on them later.

Justin Catalana

Check out screen on your linux computer. Usage should be something like: screen /device/.... BAUDRATE


You can use the -X tag to create a hardcopy of the output.



MikMo

in windows you can use the Hyperterminal app. that comes with all windows versions

westfw

I use "minicom" which is a pretty standard linux/unix app.
You'll find that most programs aimed at serial communications will have some sort of log-to-file capability.  If you're looking for something that runs invisibly in the background, or generates timestamps, or stuff like that, it might be more difficult.  You could look at the things aimed at "console management" (of server farms) like "conserver"...

mem

If you enjoy programming, another approach is to write a simple sketch in Processing that monitors the serial port and writes incoming data to a file. You could add a graph of the most recent readings if you wanted to display something like that.

Arnonh

If you are using linux you can try
Code: [Select]
tail -f /dev/ttyUSB0 > filename

walterr

I tried the tail command, it created the file but never wrote to it. I'm not to deep into unix, so maybe it's something simple.

Godge

Just digging up an old thread I started a while ago to see if anyone has any new ideas?

I have a sketch that prints values to serial - I would love to be able to save these to file and then report on them later.

Any tips?

Osgeld

#8
Jan 03, 2011, 07:49 am Last Edit: Jan 03, 2011, 07:50 am by Osgeld Reason: 1
depends on OS /software , what are you using?
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

robtillaart

mini serial capture in python
Code: [Select]

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")
           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()

Rob Tillaart

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

MikMo

If you are using a Windows PC, GoBetwino can log data from Arduino to a txt file. It's even possible to make CSV files that can be imported to databases or spreadsheet programs.

If needed GoBetwino will allow you to send data directly into Excell cells.

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

pluggy

#11
Jan 03, 2011, 09:16 am Last Edit: Jan 03, 2011, 09:17 am by stephen_t Reason: 1
The tail suggestion for linux doesn't stop reading and doesn't close the file until you stop it yourself. I program the arduino to send the stuff over and over, and use

Code: [Select]
cat /dev/ttyUSB0|head -n 5 > fred.txt

It reads 5 lines of output and saves it  to a file fred.txt and stops.

You may need to use stty to set the port to the correct baudrate etc beforehand

Code: [Select]
stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -clocal

If you're using a new fangled arduino /dev/ttyACM0 is the 'standard' port name rather than /dev/ttyUSB0

http://pluggy.is-a-geek.com/index.html

Go Up