Board, Nano clone on old bootloader, arduino IDE 1.8.10.
I'm trying to get amount of seconds from midnight for my trigger function. I'm having strange behaviour: when using uint16_t I'm not getting any overflow, but when using uint32_t, int32_t, long int I'm getting an overflow. Am I missing something?
currentTime is DateType type from RTClib library and currentTime.hour() == 15.
uint16_t currentSeconds = 0;
currentSeconds = currentTime.hour();
Serial.println(currentSeconds);
currentSeconds = currentTime.hour() * 60;
Serial.println(currentSeconds);
currentSeconds = currentTime.hour() * 60 * 60;
Serial.println(currentSeconds);
Serial output
15
900
54000
uint32_t currentSeconds = 0;
currentSeconds = currentTime.hour();
Serial.println(currentSeconds);
currentSeconds = currentTime.hour() * 60;
Serial.println(currentSeconds);
currentSeconds = currentTime.hour() * 60 * 60;
Serial.println(currentSeconds);
Serial output
15
900
4294955760