 
 void flow()
 {
-flowcount +=1;
+  flowcount += 1;
+}
+
+void calc_flow() {
+  int flow_l_s, flow_l = 0;
+  flow_interval = micros() - t1;
+  t1 = micros();
+
+  flow_l_s = flowcount * 100 / 450; // resulta em 100*m/2;
+             flow_l = flow_l_s * 1000000 / flow_interval;
+
+  Serial.println("litros:" + String(flow_l) + "vel:" + String(flow_l_s) + "\tInterval:" + String(flow_interval) + "\tCounter:" + String(flowcount));
+
+
 }
 
 
 
-
-
-void setup(void){
+void setup(void) {
   // put your setup code here, to run once:
   pinMode(flowPin, INPUT_PULLUP);
   attachInterrupt(flowPin, flow, CHANGE);
 
   Serial.begin(115200);
 
-    WiFiManager wifiManager;
+  WiFiManager wifiManager;
 
-    //sets timeout until configuration portal gets turned off
-    //useful to make it all retry or go to sleep
-    //in seconds
-    wifiManager.setTimeout(180);
+  //sets timeout until configuration portal gets turned off
+  //useful to make it all retry or go to sleep
+  //in seconds
+  wifiManager.setTimeout(180);
 
-    //reset saved settings
-    //wifiManager.resetSettings();
+  //reset saved settings
+  //wifiManager.resetSettings();
 
-    //fetches ssid and pass from eeprom and tries to connect
-    //if it does not connect it starts an access point with the specified name
-    //here  "AutoConnectAP"
-    //and goes into a blocking loop awaiting configuration
+  //fetches ssid and pass from eeprom and tries to connect
+  //if it does not connect it starts an access point with the specified name
+  //here  "AutoConnectAP"
+  //and goes into a blocking loop awaiting configuration
 
 
-    //and goes into a blocking loop awaiting configuration
-    if(!wifiManager.autoConnect("NoFlow","87654321")) {
-      Serial.println("failed to connect and hit timeout");
-      delay(3000);
-      //reset and try again, or maybe put it to deep sleep
-      ESP.reset();
-      delay(5000);
-    }
+  //and goes into a blocking loop awaiting configuration
+  if (!wifiManager.autoConnect("NoFlow", "87654321")) {
+    Serial.println("failed to connect and hit timeout");
+    delay(3000);
+    //reset and try again, or maybe put it to deep sleep
+    ESP.reset();
+    delay(5000);
+  }
 
-    //if you get here you have connected to the WiFi
-    Serial.println("connected...yeey :)");
+  //if you get here you have connected to the WiFi
+  Serial.println("connected...yeey :)");
 
 
   Serial.print("IP address: ");



}

  server.send(200, "text/plain", "hello from esp8266!");
}

void handleNotFound() {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
