Data Logger Crash

I can see it but ...

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I read the message on “CODE” but have not understood what to do

Next I will pay attention

You made changes to your code. So if you continue the topic and state that your changed code did not make a difference, you post your modified code in a new reply. That way we can see what you did and comment if necessary.

OK

Yes I changed the code to only test SD writing. Impossible to make simpler

So the code is basically the same but test only SD writing and includes Serial print to follow what happens

The many “POWER” writing is to increase the data recorded per loop because it is NOT the number of loops that count but the total writing

2000 loops gives NO problem

So:

No more PZEM and other call

Simulate only writing with well defined values

Remove LED

Use another UNO and SD Shielf 3.3V to be sure it is NOT an hardware issue

The cards are format with SdFat Formatter each time for a new trial (PS this formatter does NOT erase all the data, only the FAT)

It would be nice if some one could test the code and see what I see. However target at least 10000 loops, even more, I do not know the limit presently. 45000 loops induces the problem

Keep in mind that Arduino and Serial prints always looks perfect. It is when you want to read the SD that you see the corruptions

Please post your test sketch

The test sketch is the one poster 4h ago. It is entitled # TEST#

-------- Message d'origine --------

superquick 30 seconds-method to post a complete sketch

Just 4 steps

  1. open the sketch in the Arduino-IDE and press Ctrl-t
  2. do a rightclick in the arduino-IDE
  3. choose copy for forum
  4. paste clipboard-content into a posting
    done

If you want to read a more detailed manual how to do this you can read it here

best regards Stefan

Bearing in mind that you have not posted code a number of times despite saying that you had I can't find the sketch that you are referring to

Post #80; I also missed it because it's not posted using code tags :frowning:

You're advised to change the delay because it's soooooooooooooo slooooooooow.

I ran your code on a SparkFun ProMicro 3.3V/8MHz witha 16GB card that was formatted with SD Memory Card Formatter for Windows Download | SD Association (full format).

There are 5999 lines, filename not mangled.

I made two modifications to the code

  1. different CS pin to meet my setup
  2. adding an 'else' to hang forever once done
  if (N < 6000) {
    ...
  }
  else
  {
    Serial.println("Done");
    for (;;);
  }
}

//edit
And I removed the non-used libraries SoftwareSerial and LiquidCrystal_I2C.

Before I test this, I note the absence of a close() for the file. Does flush() update the directory entry file size and both copies of the FAT? In other words, is it just like close(), but leaves the file open, or something less? Is flush() different between SD.h and SdFat.h?

Resulta sof my trials:
12000 loops: OK takes about 1h File size 2770k. I have opened nd check : perfect
16000 loops NOT OK below what is on the SD card and none can be open
image
I hope you can see the capture of the directory

I will run it later again with more writing to file; no power at the moment. I will use a shorter delay to speed up the process.

For info the last test it in were with IDE 2.0 . And no real change. As corrupted after 16000 loop but ok for 12000

-------- Message d'origine --------

This is what I have done exactly
Is there something that miss in my last code
The topic is unchanged but code simplified to the most to avoid any possible interference with other things
And I am sure it is a problem of SD writing of big files ( Maybe 5mb... not so big indeed)

-------- Message d'origine --------

6000 lines is ok
12000 also
Problem came this after noon with 16000
Try this amount. It takes about 2h to run
I have also added the "stop" line than you proposed

-------- Message d'origine --------

I have seen that flush is not recognised sometimes in SdFat. SYNC() is then used
But as 12000 loops are ok I doubt that it is a simple flush or close line the trouble

Try my code and see what you get but at least 16000 loopd. This is in total a lot of data
If I made a mistake in sending the code, as I am not so experienced in this forum, I will resend..

-------- Message d'origine --------

I can hardly believe that you are not a low-level-troll
You have been asked so many times to post code.

Simply use a

browser

instead of email and then
You can post code by using this method that adds the code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

The code has been sent this morning through the web site. I can see it
Have you well received it?
If not please accept my excuse
This discussion about the data logger is my first one about Arduino

-------- Message d'origine --------

Which post number is the code in ?

If you can see the website then you can post the code here directly without the complication of using email. Can I suggest that you post here directly in future