Watchdogtimer

Hello,

I use this library of watchdogtimer:
https://evothings.com/watchdog-timers-how-to-reduce-power-usage-in-your-arduino-projects/

If there is a better solution ,can you mention me?

I would like to know how to sleep the entire system for 1h or 2h and wake up only max 10 sec.
It just should mesure the distance of an object and then go to sleep.

void setup () {

pinMode(GREEN, OUTPUT); // initialize the BLUE LED pin as an output
Serial.begin(9600);
pinMode(pwPin, INPUT); // SENSOR

pinMode(pwPin1,OUTPUT); //Voltage of the sensor
digitalWrite(pwPin1, HIGH); // ON voltage of the sensor

}
void loop ()
{

// HERE I introduce my initialisation of code (+ measurements with the sensor)
.......
.......

digitalWrite(pwPin1, LOW); //VOLTAGE OFF the sensor
delay(3600000); ----> )NSTEAD DOING AN DELAY I would like to sleep the system for 1h and wake up the system max to 10 sec

}

Thanks for you help

I don't know what problem you are having with the library you are currently using, but see here for a guide to using the watch dog timer (Section: Waking from sleep with a timer) any many other power saving techniques. https://www.gammon.com.au/forum/?id=11497
In principle, the watch dog timer has a maximum period of 8 seconds, but you can extend that by having multiple consecutive sleep periods.

You control the amount of time it is in the 'awake' state by setting your own timer using millis() and , when it expires, initiating a sleep operation.