Pages: [1]   Go Down
Author Topic: Data logging in Linux  (Read 537 times)
0 Members and 1 Guest are viewing this topic.
Dallas
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
nephew as a kittens
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to make a data logger, using the analog inputs from an Arduino, which has serial-over-USB. I want to use a computer running Linux to retrieve the data from the serial connection serial and store it. I want to do it as fast as possible, but I can adjust the sample rate in the Arduino firmware to slow it down as far as needed. My question isn't about the Arduino part, but about the computer part. I know just enough bash and perl to be dangerous.

I need a way to grab the serial data from the Arduino and store it in a file. How do you do that? I know how to use the serial monitor in the Arduino program, but I don't know how to redirect that to a file. Can I just write a bash script like so?
Code:
cat /dev/ttyUSB0 >> mydatafile.txt

and this just keeps running until I kill it?

My hard drive is not infinitely big, so I also need a way to somehow "scroll" or  over-write the file when it gets to a certain size. I don't know what Linux utility lets you write to the end of a file and delete the first line, but there must be one. If not I guess I can write a perl script to do that constantly, but it might slow things down.

The other option would be to create multiple files and delete the old ones as hard drive space fills up. I guess I could do that with perl.

I hate to reinvent the wheel so insight is appreciated.
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is something that is done very often.
There are many ways to do that, but I think that using Python is the most common.
There are python libraries for serial data retrieval.
This is not what I had in mind, but it's a start http://arduino.cc/playground/Interfacing/Python
You can also try 'Firmata'.
Logged

Pages: [1]   Go Up
Jump to: