Thanks for the reply. I've attached my modified code as file (to long for a post) but thats not the point. I struggle to run the unchanged "Datalogger" example of the SD library (native to IDE so no point in posting it here). It reproduces the same error I see in my modified code.
What I see in the serial monitor when I run the Datalogger example is this:
10:29:56.212 -> Initializing SD card...card initialized.
10:29:56.635 -> 438,395,373
10:29:56.635 -> 398,393,383
10:29:56.635 -> 384,381,378
10:29:56.682 -> 377,374,372
10:29:56.682 -> 373,370,368
10:29:56.728 -> 368,365,363
10:29:56.728 -> 361,357,356
10:29:56.728 -> 353,348,348
10:29:56.775 -> 346,342,341
10:29:56.775 -> 343,339,337
10:29:56.775 -> 339,335,334
10:29:56.822 -> 333,329,328
10:29:56.822 -> 325,321,320
It goes on like this for a while. After 830 samples written to the card this happens:
10:30:10.909 -> 178,176,174
10:30:10.956 -> 179,177,175
10:30:10.956 -> 180,178,176
10:30:10.956 -> 180,178,176
10:30:11.003 -> 180,178,176
10:30:11.003 -> 179,177,175
10:30:11.611 -> 178,176,174
10:30:12.219 -> error opening datalog.txt
10:30:12.826 -> error opening datalog.txt
10:30:13.435 -> error opening datalog.txt
10:30:14.042 -> error opening datalog.txt
10:30:14.651 -> error opening datalog.txt
10:30:15.260 -> error opening datalog.txt
10:30:15.866 -> error opening datalog.txt
10:30:16.474 -> error opening datalog.txt
10:30:17.082 -> error opening datalog.txt
10:30:17.643 -> error opening datalog.txt
The error message is printed for every incoming sample and goes on forever.
When I now run CardInfo from the SD Library I see this:
10:33:41.736 ->
10:33:41.736 -> Initializing SD card...initialization failed. Things to check:
10:33:43.886 -> * is a card inserted?
10:33:43.933 -> * is your wiring correct?
10:33:43.933 -> * did you change the chipSelect pin to match your shield or module?
10:34:04.395 ->
10:34:04.395 -> Initializing SD card...Wiring is correct and a card is present.
10:34:05.287 ->
10:34:05.287 -> Card type: SDHC
10:34:05.333 -> Clusters: 490466
10:34:05.333 -> Blocks x Cluster: 16
10:34:05.380 -> Total Blocks: 7847456
10:34:05.427 ->
10:34:05.427 -> Volume type is: FAT32
10:34:05.427 -> Volume size (Kb): 3923728
10:34:05.474 -> Volume size (Mb): 3831
10:34:05.474 -> Volume size (Gb): 3.74
10:34:05.521 ->
10:34:05.521 -> Files found on the card (name, date and size in bytes):
10:34:05.567 -> SYSTEM~1/ 2021-02-18 17:53:14
10:34:05.614 -> WPSETT~1.DAT 2021-02-18 17:53:14 12
10:34:05.660 -> INDEXE~1 2021-02-18 17:53:14 76
10:34:05.708 -> DATALOG.TXT 2000-01-01 01:00:00 11089
The Card is not initialized right away (has always been like this, no idea if thats normal), I have to remove it, plug it in and reset the arduino to run CardInfo (thats what you see above).
Can you see anything wrong?