 
   currentTime = millis();
   previousTime = currentTime;
-
+  
   // Flowmeter 1
   setupFlowmeter();
 

  // Pump
  setupPump();

  setupUrbanNetwork();

  // Pump
  setupWarningButton();

}

void loop() {
  // Send values
  if (checkSending()) {
    readFlowmeter();
    readWaterDistance();
  }


  }
}

void setupPump() {
  pinMode(pump, OUTPUT);
  digitalWrite(pump, LOW);
  Serial.println("PUMP_IN=0");
}

void setupElectrovanne() {
  pinMode(electrovanne, OUTPUT);
  digitalWrite(electrovanne, LOW);
  Serial.println("ELECTROVANNE=0");
}

void setupUrbanNetwork() {
  pinMode(urbanNetwork, OUTPUT);
  digitalWrite(urbanNetwork, HIGH);
  Serial.println("URBAN_NETWORK=0");
}

void setupFlowmeter() {
  pinMode(flowmeterIn, INPUT);
  pinMode(flowmeterOut, INPUT);
  attachInterrupt(digitalPinToInterrupt(flowmeterIn), increaseFlowmeterInCounter, RISING); // Setup Interrupt
  attachInterrupt(digitalPinToInterrupt(flowmeterOut), increaseFlowmeterOutCounter, RISING); // Setup Interrupt
  sei();                                             // Enable interrupts
}

void increaseFlowmeterInCounter()
{ 
   flowmeterInCounter++;
} 

void increaseFlowmeterOutCounter()
{ 
   flowmeterOutCounter++;
} 

void readFlowmeterIn() {
  // Every second, calculate and print litres/hour
  // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in +/- 3% range)
  flowmeterInResult = (flowmeterInCounter * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour 
  flowmeterInCounter = 0;                   // Reset Counter

  Serial.print("WATER_FLOW_IN=");
  Serial.println(flowmeterInResult, DEC);
}

void readFlowmeterOut() {
  // Every second, calculate and print litres/hour
  // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in +/- 3% range)
  flowmeterOutResult = (flowmeterOutCounter * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour 
  flowmeterOutCounter = 0;                   // Reset Counter

  Serial.print("WATER_FLOW_OUT=");
  Serial.println(flowmeterOutResult, DEC);
}

