i need your help, ive bean working on this for a long time and everything seems to be alright except that it doesn't work. i tried to copy each and everyone of the example code i could (which all worked alone), but i cant seems to make it work inside "MY" code. using standalone example code i can write to the SD card and read it, it even detects when the card is not present. using the SD information gathering example code i can see that all is working.
am trying to make a lithium battery capacity tester (4.2v -> 3v), a 1.2amp constant load will be attached to the battery with the relay in series. the arduino serve as a auto-shutoff when the battery reach 3volt, and logs the voltage and time to be used later as a graph.
Problem
-i keep getting an "error opening test2.txt" error
-the code is stuck as if the voltage is bellow 3v, even thought it read 5v (connected to arduino VCC). even when i press the gobutton it doesnt switch
[Card Info]
Initializing SD card...Wiring is correct and a card is present.
If you can't open test3.txt, print a message saying that you can't open test2.txt. I'll bite. Why?
The manipulations of timeValue tell me that you haven't a clue. The function name that returns the value indicates that the function returns a string or a String. You cast that to an int, and then cast the int to a String. That hasn't a hope in hell of doing anything useful.
Post a link to the library that defines the class that rtc is an instance of.
Don't attach code that is one 1660 character. DO use Tools + Auto Format before posting code.
The function returns a pointer to a string. Casting that to an int is pointless. Casting it to a String is equally pointless.
Casting voltage to a String is wrong, too.
Do not even consider using Strings. Two writes to the file use a lot less resources than trying to make everything into Strings so that you can concatenate them (especially when you are not making the things into Strings even remotely correctly).
Create a simple program that does nothing more than open and write to a file. Connect nothing bu the SD shield. Does that work?
PaulS:
You create an instance called rtc. That is an instance of a class that is defined in some library. You need to post a link to that library.
Additionally, most RTC libraries automatically create one instance of the RTC object by default, since there is no sense to having two RTC's I guess... so you shouldn't be doing it if that is the case.
yes, the readwrite example from the SD arduino library works.
i tried to replace my write line with only myFile.println("hello"); it still doesnt work.
well i guessed that since in the serial monitor it does give me the time, nicely pakaged and all that it was just a matter of printing that line on the SD card.
i think the problem is the myFile write stuff, even when i change my string stuff with only myFile.println("hello");
it doesnt work.
pomelum:
well i guessed that since in the serial monitor it does give me the time, nicely pakaged and all that it was just a matter of printing that line on the SD card.
I see. Is the "it" you are referring to an RTC example sketch, or an earlier version of your program? Because you're going to have to be careful not to mess up the RTC logic if you have no idea how it works.
tying to directly : myFile.println(rtc.getTimeStr);
error:
Datalogger4:71: error: no matching function for call to 'File::println()'
like i said, recording time and voltage is the easy part. ill figure it out later. am just trying to make the thing save something on the card, and even erasing all the myFile.println like and only putting myFile.println("hello");
it doesnt work. i still get the error opening test2.txt
yes, i can read and write on it with the test code. some test code even give information about the card, size and filesystem type. they all work. but taking the same line and incorporation them into my code doesn't work.