Cycles per second in loop varies greatly with lots of things (platform, code etc.) however there must be a way to work around this. I modified some example code from RTClib softrtc to count the loops between output from the routine. It varies wildly but since you can enumerate each point at which it rolls over between seconds you can simply divide that raw count number by the rollover iteration and come up with a fraction of a second. I am trying to use this code to record barograph data from a bmp180 and data from a microphone array.
I am a raw beginner but the following code will give someone smarter than me a way to work it out.
I also found a crude fix for another problem and the answer and source are in the code.
This a routine that I found in the examples section of RTClib code.
I think that by watch
// Date and time functions using just software, based on millis() & timer "Softrtc"
#include <Arduino.h>
#include <Wire.h> // this #include still required because the RTClib depends on it
#include "RTClib.h"
#include <time.h>
// Was getting error collect2.exe error ld returned 5 exit status
// Fix was at many cases of ld.exe crashes. (on windows xp). - IDE 1.x - Arduino Forum
int y = 0;
int z = 0;
int w = 0;
//I was trying to figure out a way to get timing info below the 1 second threshold
//so I used one of these variables in my tests.
//First time I ran this i had y=y++ and it was kicing over each second at 1sec/1190.
//now with this new line it rolls over at 1sec/1294
//now just tried y=y+1 and it rolls over at 1 sec/674
RTC_Millis rtc;
void setup () {
Serial.begin(57600);
// following line sets the RTC to the date & time this sketch was compiled
rtc.begin(DateTime(F(DATE), F(TIME)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
rtc.adjust(DateTime(2015, 12, 03, 7, 46, 0));
}
void loop ()
{
DateTime now = rtc.now();
//Serial.print(now.year(), DEC);
//Serial.print('/');
//Serial.print(now.month(), DEC);
//Serial.print('/');
// Serial.print(now.day(), DEC);
//Serial.print(' ');
// Serial.print(now.hour(), DEC);
// Serial.print(':');
//Serial.print(now.minute(), DEC);
// Serial.print(':');
Serial.print(now.second(), DEC);
y=y+1;
//y++;
Serial.print(" /");
Serial.println(y);
Serial.print('/');
}