Go Down

Topic: How to write newline to sdfile? (Read 649 times) previous topic - next topic

dieselboris

Hi all,

i try to write sensor values to a line in a SD file, i use sdfatlib. It works OK.
But: i want to write a newline ("\n") every 5000 characters.

I thought of doing:

Code: [Select]

if (str.length() > 5000){
   sdfile.print("\n");
}


but it does not work very well. Which character should i use?

PaulS

Quote
but it does not work very well. Which character should i use?

Ah, the famous "that didn't work" statement.

That code does something. You expect(ed) it to do something. What either thing is is not clear.

As a hint, though, the class you are using most likely derives from the Print class, this has both print() and println() methods. The println() methods do know how to place a carriage return AND line feed in the file.

Your call is adding one, but not the other, which, to some applications, makes a difference.

Tom Carpenter

If say you were using Windows, and say Notepad to view the files, you would need to declare the Carriage Return character aswell as windows uses <CR><LF> to move to a new line. You could try sdfile.print("\r\n").
~Tom~

Go Up