Using ESPhome to build a water flow rate meter

Finally. Let me explain better. Need some help/advice.
This esphome is making me crazy.

I have a canister on my aquarium and installed this YF-B5 on it. It’s nominal flux is 1000L/h.
All details of my project I’m putting in this topic:

So, I programmed the ESPHome on a ESP32 and it was not working. I was getting no signal, no pulses. I tested before on a test circuit using a ESP8266 (d1_mini) and it was working. So I decided to back to D1 mini. It also stopped working, until I remove the divider resistors (5V → 3.3V) and plugged the wire directly on the pin.

Now I have pulses ! But depending on how I configure esphome, I have a different result.

  1. First problem/doubt:
    I’ve seen some calculations above, multiplying the factor 6.68 to 60 and getting L/min. My frequency formula is F=6.68*Q.
    Considering F = Hz, is it the number of pulses the sensor outputs ? Does it mean L/min ? Because If I get this number and divide by 6.68 I will get the Q=L/min. So I don’tknow why are you multipliyng the factor by 60 and dividing the “x” (the value read from the sensor) by this number.

  2. SECOND doubt:
    I made just like you did, but if I change the way I code ESPHOME, I’m getting different results, I don’t know why:

If I declare like this:

 - platform: pulse_counter
    name: "pulse flux"
    id: freq_fluxo_sala
    pin: D6

I’m getting a decent result:

Flux Canister         815,3 L/h
pulses                326.785 pul/min
Liters   290,4 L

Obs.: the lambda is calculated and published to a template sensor:

!lambda return ( x / ( 6.68 * 60 ) );   #to return L/h

But if code configuring the PULL_UP resistor:


 - platform: pulse_counter
    name: "pulses_min"
    id: freq_fluxo_sala
    pin:
      number: GPIO12     # (I also tried D6 and number 12) 
      mode:
        input: true
        pullup: true 

I get a very different result:

Flux Canister      6,1 L/h
pulses               2.436 pul/min
Liters                112,2 L

So, could somebody explain me how to get the right formula or what is those variables mean ???

Thanks.