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.
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
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
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)
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
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..
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
press Ctrl-T for autoformatting your code
do a rightclick with the mouse and choose "copy for forum"
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
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