Go Down

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


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.


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.


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


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


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.


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


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.


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?


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?


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

       # do some other things here

   print "Stop Monitoring"

""" -------------------------------------------

print "Start Serial Monitor"

BAUDRATE = 115200


Rob Tillaart

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


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.



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


Go Up