Not tested, but this might get you started:
SYSTEM_THREAD(ENABLED)
unsigned long interval = 60 * 60 * 1000; // How often to Pump the Water
unsigned long previousMillis = 0 ; // store last Pumping Time
volatile int waterPulse = 0; // Pulse Counter
int targetPulse = 8228; // 8228 Pulses = 1 Gallon. Verify with a pump test
void setup() {
Serial.begin(9600);
// Flow Meter
pinMode(D6, INPUT_PULLUP); // THE WATER METER
attachInterrupt(D6, flow, FALLING); // Interrupt for Water Meter
} // End Setup
void loop() {
if (millis() - previousMillis >= interval) {
pumpWater(); // Pump the Water Down
}
} // End LOOP
void pumpWater() {
previousMillis = millis();
// Turn ON your Pump Here
while ( waterPulse <= targetPulse ) {
Particle.process();
}
// Turn off your Pump Here
waterPulse = 0; // reset the pulse counter
}
void flow () // ISR
{
waterPulse++;
}