- Although not strictly required, maybe use parentheses around
millis() - sendDataPrevMillisfor readability; - I guess you will have initialised
sendDataPrevMillisto 0 but the first time you assignsendDataPrevMillistomillis()some time will have elapsed since you evaluated. So callingmillis()twice will give different results. That makes it less easy to see what is going on.
Suggestion to try:
long HALFHOUR = 30 * 60 * 1000L;
if ( (millis() % HALFHOUR ) == 0L ) {
measure and send ....
}
long HALFHOUR = 30 * 60 * 1000L;
if ( (millis() % HALFHOUR ) == 0L ) {
//measure and send
//....
}
Hope this helps.
NB: % is what is called the 'modulo operator' see: https://www.geeksforgeeks.org/modulo-operator-in-c-cpp-with-examples/