Hello everyone, hope you’re all doing great!
Setup:
The Rain Gauge output is connected to a pull-up resistor, so it generate LOW pulses when there is rain, something close to this ¯¯¯¯|_|¯¯¯¯.
Goal and Explanation:
As you may have figure out, I would like to be able to read this pulses every time they occur, so first I had to use the Arduino Interruption with a simple debounce to not count the same pulse multiple times.
attachInterrupt(digitalPinToInterrupt(interruptPin), countBucket, RISING);
[...]
void countBucket() {
noInterrupts();
pulseTime = millis();
if ((pulseTime - lastPulseTime) > acceptedInterval ) {
state = !state;
count++;
lastPulseTime = pulseTime;
}
interrupts();
}
The code above (plus the omitted part) works just fine, I can count the sensor without any problem.
Because the board is always working, the battery isn’t able to last much time and so I decided to use the [Adafruit Sleepy Dog to make it sleep most of the time and with this the battery last a really long time.
Issue:
However, if everything worked i wouldn’t be here (rsrsrs) and while sleeping I can’t count the pulses right. When the board get the first pulse, it wakes up and then, on the second one if the board is still wake the pulse will be counted once, otherwise it will just wake it up again. Does anyone know if it is possible to count this while sleeping or to wake it up and make this first pulse be counted?](GitHub - adafruit/Adafruit_SleepyDog: Arduino library to use the watchdog timer for system reset and low power sleep.)](https://www.sparkfun.com/products/14713)