Pages: [1]   Go Down
Author Topic: Collect via serial information and store them in a database  (Read 795 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear all,

I have my arduino (with sensors and buttons) connected via usb to a linux machine. I have programmed the arduino to answer to specific serial commands to give the value of sensors attached or to write directly (live) the status of a button if pressed.
I would like to make some sort of serial listener on the linux machine, that can intercept the button status change, as well program a scheduled script that asks via serial the values of the sensors put all these data in a database.
Does anyone of you have some suggestions, advices or some guidelines i can follow?
Thank you,
dk
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Almost any programming language can do that. Try Python.
Most  important is that you need to pack your data between field and record separators, or use IDENTIFIERS
e.g.
TI=01001;t1=55;t2=57;t3=75
TI=01002;t1=56;
TI=01003;t2=58;t3=76
TI=01004;t3=79
every line has  fields and every field is named, so only changed fields need to be send
useful for lots of sensors with few changes.

alternative is to have fixed # of fields with fixed position (preferred mostly)
e.g.
01001;55;57;75
01002;56;57;75
01003;56;58;76
01004;56;58;79

for human readability a tab char is a better separator than ;
both can import in Excel

Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: