Arduino SD library

Check if you are closing the file before removing the SD. Files may not be updated if you don’t. This is a normal behavior (and one of the potential problems I mentioned in another thread a while ago). Or if you keep the file open, you have to flush the file with File::flush() after a write, or you can open the file with the O_SYNC flag to flush every write automatically to the SD.

What about the \AppData\Local\Arduino15\packages\artekit\hardware\stm32f4\1.0.1\libraries\SD\examples\ReadWrite\ example?

Yes I’m using that example.
it reads nothing from the file, both if the file already exists or has to be created (and it’s not)

So you are seeing the following at the serial port, excluding the last line (testing 1, 2, 3)?

Initializing SD card...initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.

If so, it is very strange. I would say to try with another SD card.

I’ve tried this:
to retrieve the number od bytes written by the print function

Serial.println("Writing to test.txt...");
num = myFile.println("testing 1, 2, 3.");
Serial.println(num);
// close the file:
myFile.close();
Serial.println("done.");

and I get always zero bytes written

Initializing SD card...initialization done.
Writing to test.txt...
0
done.
test.txt:

that’s my model.

ok, is the SD card model.
I used the SD of a saber sound card and it works. (it’s a SanDisk 4GB class 4 )

By the way, which one are you using @Ivan ?

A bunch of them (around 10 different models/brands). I don’t have precisely the one you posted (I have a 64GB kingston). I am about to order a couple of those.

ok so I’m quite unlucky :joy:

I tried to test as much brands/models as I can. Still have to try with some problematic Sandisk.

If you can, please post a list of the working ones, so we have a reference.

For reference, this is the working SanDisk 4GB Class 4.

Thank you.

We should receive these days 2 different models/brands (the ones beta testers have reported problems).

I should put a list of tested SDs in a separate thread or in the documentation. There is also a new improved SD handling code in queue for version 1.0.2.

Hi @Mangaman.

We’ve ordered 8GB SD card from two different places and we received 16GB instead! Could it be that they are going out of production? How long do you have this SD?

By the way, these SD work without problems.

Hi @Ivan, i got it from Amazon, bought last year.

got one today from Amazon.

Here is the link:
https://www.amazon.it/gp/product/B001CQT0X4/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

Ok. We’ll try with that vendor.

Have also these two.
I will try them asap.


@Mangaman please try also this with the SD that is not working for you.

Thank you.

Hi @Ivan,
with the new routines it works. Thanks.

What did you change? some timings in the write process?

Mostly initialization code and pin settings.