Go Down

Topic: Reading and using an especific line from datalog (Read 269 times) previous topic - next topic

tsenna

Hello guys!
I´m working on a project for my college, and I stumbled upon some problems, but the one that I would need urgent help is this.

I´m trying to program a temperature controller, and I´m doing a good job.
The controller logs every data I need into the archive inside the SD card, on the SD module, so later I can create graphs and analise what happened.
The problem is that a normal test would take 30 days, and the program have some different temperature decisions based on the day the test is, so after 30 days of my first test, I realize that the power in my city was off for several times. The consequence of that is, when the controller turned off and then on again, all the proccess started from the beginning, the controller always thought it was Day 1! Max I could reach was 6 days...

So I would not like to use an extern battery.
I would like when my controller turn on, to identify the last day registered on the log and continue from there.

The table I print is like this.

Day Temp TempAv RelayState
1       19     20           0
1       20     20           0
1       21     20           0
1       22     20           1
1       21     20           1
1       20     20           1
1       19     20           0
2       19     20           0
2       20     20           0
2       21     20           0
2       22     20           1
2       21     20           1
2       20     20           1
2       19     20           0



I know some commands to read the file, but it reads it all.
And when it reads, reads as a string.
I´m using the SdFat.h library.

Thanks all :)

PaulS

Quote
I know some commands to read the file, but it reads it all.
You don't NEED to read the whole file. You can get the length of the file, and position the read cursor anywhere in the file.

The problem is knowing where to position the cursor. If the records were fixed length, there is no problem.

Quote
And when it reads, reads as a string.
Why is that a problem?
The art of getting good answers lies in asking good questions.

tsenna

Well,
when it reads "1", i cant use on my variable day, because it´s not an integer and cant operate...
I read in some forums the use of EEPROM in the case the Arduino turns off..
I'm reading about it, what do you think?

PaulS

Quote
when it reads "1", i cant use on my variable day, because it´s not an integer and cant operate...
atoi() can convert a string to an int. If you read a '1', instead of a "1", you could convert to an int by simply subtracting '0' from the character.
The art of getting good answers lies in asking good questions.

Go Up