Page 1 of 1

Data logging and storing in separate files with time stamps

Posted: Tue Jan 13, 2015 11:58 am
by ggnamita
Hello,

I have tried to create a serial data logger using the pi and a small tracer that can be used in a car. It logs in various information about the car like the GPS information, the temperature,the battery information and various other things and could be used for trouble shooting in case of some problems in the car. I have successfully been able to connect to the logger and access the trace data via the raspberry pi. I store all the information into a file called 'gps-log.py' .

But I dont want all the data to be stored in the same file by just appending it. I want to try and save the log data in different files with different time stamps. I have not much idea on how to create separate files with different time stamps.
i use python for programming and I wanted the log data to be stored every 1 mintue.
Please help.I have synced the raspberry pi's time with the GPS in the serial device.

Any advice or suggestion would be helpful

Namita.

Re: Data logging and storing in separate files with time sta

Posted: Tue Jan 13, 2015 1:43 pm
by hampi
Probably the easiest way is to install SQLite. Each database is a single file. You can find good documentation about SQLite from web.

For example create a new database testbase.db and create an empty table temperature with a time stamp to it

Code: Select all

sqlite3 /tmp/testbase.db
sqlite> create table temperature(no integer primary key, ts timestamp default current_timestamp, data real);
Now insert some data

Code: Select all

/usr/bin/sqlite3 /tmp/testbase.db "insert into temperature (data) values (22);"
and check that it is in the database

Code: Select all

sqlite3 /tmp/testbase.db
sqlite> select * from temperature;

Re: Data logging and storing in separate files with time sta

Posted: Tue Jan 13, 2015 3:25 pm
by jamesh