Go Down

Topic: Several questions about datalogging project (Read 2990 times) previous topic - next topic

lomanas123

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: [Select]
//Open the Data CSV File
  File dataFile = SD.open("test.txt", FILE_WRITE);

test1,
test2,
etc
i have tried
Code: [Select]
File dataFile = SD.open("test"+String(k)+".txt", FILE_WRITE);
but it's [font=Verdana]not [/font]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

Nick_Pyner

#1
Feb 27, 2013, 02:56 pm Last Edit: Feb 27, 2013, 03:46 pm by Nick_Pyner Reason: 1

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: [Select]
//Open the Data CSV File
 File dataFile = SD.open("test.txt", FILE_WRITE);

test1,
test2,
etc
i have tried
Code: [Select]
File dataFile = SD.open("test"+String(k)+".txt", FILE_WRITE);
but it's [font=Verdana]not [/font]working



Couldn't you just go

Code: [Select]

     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.

lomanas123

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: [Select]
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!

robtillaart


you can use sprintf to print to a char array.

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

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

lomanas123

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

thanks.

Now anybody has an idea how to time the measuraments?


michinyon

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.

lomanas123

sprintf()
works correct
for char[];

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

Nick_Pyner

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?

Ahto

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?

lomanas123

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

robtillaart

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 ;)
Rob Tillaart

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

lomanas123

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

Hi,
for filedate/time google for something like this,I think it´s somewhere in the Fat16 Libs examples
Code: [Select]

/*
* 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
http://robertgetzner.com/PersonalWordpress/category/computer/arduino/

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy