voidloop does not repeat all the loop

Hello everybody :slight_smile:

I am working on my project : automated greenhouse.

Using a clock DS3231 is necessary for repeated actions everyday ( watering, light, ventilation, humidity in the air,…)

That’s the biggest problem, i use the libraries Time, TimeAlarms, Timelib, and i exctracted a loop from their exemples.
No problem here, i got the right Time & date on my LCD with syncrhonisation.

At a certain time, some relays must be ON.
So in the loop, i put a condition of time, IF we are in the conditions of time, then the relay goes ON.

The probleme is that the loop works , but does not refresh some lines everytime ;
look at the line
" int sec = (now.second(), DEC);
Serial.print(sec);"

it should print everytime the second number, but it always give back 10, and it never refresh !

And that is the same for my relays, it will only consider the initial time ;

the light must be ON if minutes are more than 10, if i start before 10 it will be OFF and won’t go ON at 10mins or more…
And if i start after 10 it will stay ON forever and won’t go OFF at the new hour with 0 minutes…

Does someone has a good idea ? :slight_smile:

Using clocks makes everything chinese to me :o

it should print everytime the second number, but it always give back 10, and it never refresh !

It does that because that is what the comma operator does.

Just because
Serial.println(now.second(), DEC);
makes sense does NOT mean that you can drop the Serial.println part and assign the result to a variable.

   int sec = now.second();