Pages: [1]   Go Down
Author Topic: Several questions about datalogging project  (Read 2251 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to create a special datalogger for reading tiny amounts o voltage diff,
however i have 2-3 questions about the datalogging problem.

first: i want to create several logs in the form of
Code:
//Open the Data CSV File
  File dataFile = SD.open("test.txt", FILE_WRITE);
test1,
test2,
etc
i have tried
Code:
File dataFile = SD.open("test"+String(k)+".txt", FILE_WRITE);
but it's not working



second:
The dates on my output
all the text file on the Sd card are dated 1/1/2000
[img][file:///C:/Users/nerito/Pictures/arduino.jpg/img]


third :
any ideas how to uses floats on sd?

thank you in advance


* arduino.jpg (18 KB, 612x111 - viewed 35 times.)
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2193
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to create a special datalogger for reading tiny amounts o voltage diff,
however i have 2-3 questions about the datalogging problem.

first: i want to create several logs in the form of
Code:
//Open the Data CSV File
  File dataFile = SD.open("test.txt", FILE_WRITE);
test1,
test2,
etc
i have tried
Code:
File dataFile = SD.open("test"+String(k)+".txt", FILE_WRITE);
but it's not working


Couldn't you just go

Code:
     myFile = SD.open(filename, FILE_WRITE);
  myFile.print(test1);
  myFile.print(",");
  myFile.print(test2);
  myFile.print(",");

etc
Quote
second:
The dates on my output
all the text file on the Sd card are dated 1/1/2000
[img][file:///C:/Users/nerito/Pictures/arduino.jpg/img]

Your Arduino has no idea what the date is and I guess the 1/1/2000 is just windows putting a name to nothing.
Your best bet is to get a real time clock and use that to name your files according to date and time. I record the time in the data and just use the date for the filename  - 20130218.csv

Quote
third :
any ideas how to uses floats on sd?

Just declare your variable as a float and myfile.print them to SD.
« Last Edit: February 27, 2013, 09:46:48 am by Nick_Pyner » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Just declare your variable as a float and myfile.print them to SD.

I was so used of converting everything to String that i didn't thought it
So thanks!!

In the otherhand the other two answers didn't not help because:
Code:
myFile = SD.open(filename, FILE_WRITE);
  myFile.print(test1);
  myFile.print(",");
  myFile.print(test2);
  myFile.print(",");

i don't want to write something different i want to give different filename!

For the date i have to find a way to change it automatically...

Thanks in advance!
Logged

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


you can use sprintf to print to a char array.

something like  sprintf(filename, "test_%02d.csv", k);  google for exact syntax.
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's a good idea, it worked and it is a clever one.

thanks.

Now anybody has an idea how to time the measuraments?

Logged

Offline Offline
Faraday Member
**
Karma: 61
Posts: 2833
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought sprintf() doesn't work ?

If you want to know the time of your recordings,  you are going to need to get a real-time-clock module,
about $3 from ebay plus a little battery.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sprintf()
works correct
for char[];

about the time module have you got any suggections?
what to buy i mean
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2193
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 have bought four of these.

http://www.ebay.com.au/itm/270985342203?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

How cn you go wrong at $2-36 incl postage?
Logged

Tampere, Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm learning Arduino RTC, too.

There seems to be 2 ways to go:

a) DS1307:  communication= I2C-bus, cheap, probably the right way to go, Nick's l
link is to one of these.
b) DS3234: communication = SP-bus, more accurate, more money...

There are Arduino libraries for both, maybe I2C is more easy?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone knows and can suggest any external low noise ADC for arduino?
Logged

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

Today I got one of these - https://www.adafruit.com/index.php?main_page=adasearch&q=ads1115 -
not tested, not even read the datasheet, but it is capable of a few 100 samples @16 bit per second.
at 16 bits I expect low(er) noise

- http://adafruit.com/datasheets/ads1115.pdf -

at least it is an external one smiley-wink
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 21
No limit
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks but since i am in europe i can't order from adafruit and the ADC you suggested is the smallest i have ever seen. I will never be cable of soldering it
Logged

Offline Offline
Newbie
*
Karma: 3
Posts: 39
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
for filedate/time google for something like this,I think it´s somewhere in the Fat16 Libs examples
Code:
/*
 * User provided date time callback function.
 * See Fat16::dateTimeCallback() for usage.
 */
void dateTime(uint16_t* date, uint16_t* time) {
  // User gets date and time from GPS or real-time
  // clock in real callback function
 
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(year, month, day);
 
  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(hour, minute, second);
}

Just in case you have your arduino connected to a PC, you can set the date/time via serial. Of course not possible, if your arduino is not connectd.
Best, Robert
Logged


Pages: [1]   Go Up
Jump to: