anton74:
It probably looks bad, sorry for that.
It looks bloody terrible... A few For.... next loops can fix all those long lists of ifs and serial prints, surely? The last time I saw stuff like that, it was in Fortran. It was fixable then, so it must be fixable now. Having said that, you're telling me it works, so it can wait - although the local tigers might snap at you in the meantime.
I incorporated your suggestion with the modulus thing at the end of the loop(). It seems to work OK now.
OK, that's good
However, I am not sure about the proceed in the setup(). Even without this, the code waits until the minutes turn 10 or increments of 10, and then starts acquisition every 10 min.
This (ahem) speculative code is intended to do nothing until the correct time, i.e. don't proceed with the setup. It came from the test for the presence of a kosher SD card. I understood you wanted to start at an "exact round ten minute" I don't understand how you are doing that.
The only thing I am not happy with is the delay(1000) at the end of the loop(). Without this delay, the data is introduced into the Excel several times.
This is because, without the delay, the loop is whizzing round at blinding speed, for no sensible purpose, and thus reading seconds=0 several times, hence my previous about loop time. Putting in a delay of one second fixes the problem and, if you have nothing better do do with the time wasted in the delay, is an entirely legitimate method of doing so. Maybe not very elegant. If you have lots of things going on, you probably need to tune the delay. My main project has a quite accurate one second loop by inserting an 850ms delay.
You could use the clock and a proceed condition, whereby you only advance when the seconds read is not the same as the previous seconds reading. There is also a one second square wave output from the RTC, and you just wait for a change in state therefrom. That's the mysterious SQW pin. I have never actually used either method, but they are useful to know about.