technogeekca:
I am trying to convert millis to HRS:MINS:SECS as in 01:12:34.
I was lead to the DateTime Library which requires the Wiring Library.
I've downloaded DateTime but I cannot find the Wiring Library anywhere.
These are very old Libraries and my searches have been fruitless for a substitute.
Can anyone give me a direction to go so I can use a newer Library or any other suggestions.
You don't need any library to do simple date and time calculations.
Here is a small example sketch to show millis() since last reset in hh:mm:ss format.
Upload code and open serial monitor at 9600 Baud and watch!
void setup() {
Serial.begin(9600);
}
void loop() {
unsigned long runMillis= millis();
unsigned long allSeconds=millis()/1000;
int runHours= allSeconds/3600;
int secsRemaining=allSeconds%3600;
int runMinutes=secsRemaining/60;
int runSeconds=secsRemaining%60;
char buf[21];
sprintf(buf,"Runtime%02d:%02d:%02d",runHours,runMinutes,runSeconds);
Serial.println(buf);
delay(1000);
Why are you wanting to take rollovers into account?
Is your application running more than 50 days uninterrupted?
In case yes: DO NOT USE MILLIS, COUNT SECONDS instead!
You can break down millis() into a seconds counter which is NOT affected by rollovers after about 50 days.
Please feel free to ak in case you don't know how to do it.
And be warned: Internal time counting using the on-board oscillator/or ceramic resonator as a clocking source may be wrong up to 0.8%.
So counting 1000 seconds with internal timing might be something between 992 and 1008 seconds, actually!
Is that OK for you? Or do you need more accurate timing?
In case you need accurate timing, use an RTC module for clocking, preferably a high-precision clock module like DS3231.