Water meter incorrect readings

Hello everyone,
I have a water meter implementation based on ESP, and build following this (very helpful by the way) site: Build a cheap water usage sensor using ESPhome and a proximity sensor - PieterBrinkman.com
The sensor that I use is this one:
image

My problem is that from time to time the water consumption readings are incredibly high and the displayed values could never be real, in my situation.
As we can see in the following graphs, between 5:00 and 6:00 in the morning there is a consumption of 4191 liters of water, while in reality it should be something like 25L (usually used by the water softener for internal cleaning)
On the same graph, a little later (between 6:00 and 7:00) we can see a consumption of 26L and between 7:00 and 8:00 a reading of 57L, which are more realistic.
Here are the graphs:

And this is the code that I use for this ESP sensor:

esphome:
  name: compteur-deau
  friendly_name: Compteur d'Eau

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxx"

ota:
  password: "xxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Compteur-Deau Fallback Hotspot"
    password: "xxxxxxx"

captive_portal:

sensor:
- platform: pulse_counter
  pin:
    number: GPIO12
    allow_other_uses: true
  update_interval : 6s
  name: "water pulse"
  id: water_pulse

- platform: pulse_meter
  pin:
    number: GPIO12
    allow_other_uses: true
  name: "Water Pulse Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
  total:
    name: "Water Total"
    unit_of_measurement: "liter"
    id: water_total
    state_class: measurement
  
- platform: pulse_meter
  pin:
    number: GPIO12
    allow_other_uses: true
  name: "Water Pulse Meter"
  unit_of_measurement: "liter/min"
  icon: "mdi:water"
  total:
    name: "Water Meter Total"
    unit_of_measurement: "m³"
    id: water_meter_total
    accuracy_decimals: 3
    device_class: water
    state_class: total_increasing
    filters:
      - multiply: 0.001
  
- platform: template
  name: "Water Usage Liter"
  id: water_flow_rate
  accuracy_decimals: 1
  unit_of_measurement: "l/min"
  icon: "mdi:water"
  lambda: return (id(water_pulse).state * 10);
  update_interval: 6s
  state_class: measurement

As this phenomenon is random, I was wandering if this is caused when the metallic part of the water meter, the one that turns when water is used, is stopped just below the sensor. When this happens, the red LED of the sensor remains on.
My thoughts is that it could make that in this situation the system continues to count as long as the sensor remains activated by this metallic part, even if there is no water consumption.

image

Maybe there is something else, or maybe there is a parameter to avoid this continuous count.
Any help would be greatly appreciated :blush:
Thank you

I have got some “inspiration” from Watermeter uitlezen in Home Assistant met Esphome - Huizebruin.nl.
It’s in dutch but maybee you could have a look at the yaml. Or use ggle translate.
It’s normal for the red led to remain on, as long as it goes on and off if water is flowing thats oké.

Gpio12 on Esp-01? Are you sure??
Also what’s the exact model of your sensor?

I think that you pinpointed the problem :slightly_smiling_face:
The ESP model that I use is the D1 mini:
image
The sensor exact model is: LJ18A3-8-Z/BX-5V and the signal is connected on D6 pin of the D1-mini module which is the GPIO12
I changed the board to

esp8266:
  board: d1_mini

Recompiled and wait to see what the readings will be now.
Thank you

Ok, finally, after having changed the borard type using:

esp8266:
  board: d1_mini

readings are correct again :slightly_smiling_face:
Thank you for hour help :slightly_smiling_face: