Create log files at intervals

I have a couple of Arduino sensors transmitting data to a serial to USB. This is connected to a COM port in my Mac at ~1Hz. I can connect to the devices and see the data as expected using Coolterm and screen through the terminal and can log the data for a specific session using Coolterm (this requires clicking 'save to file' and manually stopping when I want).

I would like to be able to collect and log data over longer periods of time and have .txt files of the collected data automatically created and saved at specified intervals (create one file per hour).

I've scoured for ways to do this using Coolterm and Zterm and can't figure it out. Is there perhaps a way to do it using the Mac terminal and some shell scripts? Am I overlooking something basic? Thanks all.

agmeyer4:
I've scoured for ways to do this using Coolterm and Zterm and can't figure it out.

In that case, you might look at doing it on the Arduino instead - where is it easy to do with local SD card. This brings its own benefits - no need to have PC connected all the time, and you can download the files at leisure. You can use date/time as the filename and create a new file on the change of hour.

An easy way to do that with Arduino alone is to use OpenLog, which is a separate module that creates/reads/writes files on a uSD card. 3.3V only, so if you use this with a 5V Arduino, be sure to put a ~4.7K resistor in series with Arduino TX->OpenLog RX.

Note that if you store the unix date/time stamp (4 bytes) in each line of your data file, there is no need to deal with multitudes of files. Check out the Arduino Time library.

agmeyer4:
I have a couple of Arduino sensors transmitting data to a serial to USB. This is connected to a COM port in my Mac at ~1Hz. I can connect to the devices and see the data as expected using Coolterm and screen through the terminal and can log the data for a specific session using Coolterm (this requires clicking 'save to file' and manually stopping when I want).

I would like to be able to collect and log data over longer periods of time and have .txt files of the collected data automatically created and saved at specified intervals (create one file per hour).

I've scoured for ways to do this using Coolterm and Zterm and can't figure it out. Is there perhaps a way to do it using the Mac terminal and some shell scripts? Am I overlooking something basic? Thanks all.

Sounds like a job for the Python pyserial package to me.