Noise / false count on pulse counter with ESP32

Hello,

I had two water meters (reed switch : GIOANOLA Compteur d'eau chaude à impulsion - 3/4p 1 imp/litre Eco Energie) that worked fine with Arduino + My Sensors.

Because I want to go to EspHome and get rid of Arduino and My Sensors, I converted them to EspHome with an ESP32… but I get incorrect pulse count !

I have false pulse that appear from time to time, for exemple below, all the pulses before 18:00 were false.
I didn’t had this issue with Arduino.

What should I change to get accurate results ? External PullUp ? Schmitt Trigger ? Config change ?

Thanks a lot for your help !

Result

ESP Home Config
Verbose, but I tryed a lot of configuration …

sensor:
  - platform: pulse_counter
    use_pcnt: false
    internal_filter: 100ms
    count_mode: 
      rising_edge: DISABLE
      falling_edge: INCREMENT
    id: water_city_id
    pin:
      number: 22
      mode:
        input: true
        pullup: true
    name: "Water City Consumption"
    unit_of_measurement: 'L/min'
    accuracy_decimals: 2
    total:
      unit_of_measurement: 'L'
      name: 'Water City Total'
      accuracy_decimals: 0

Old arduino sketch
Choosen parts of the code :slight_smile:

pinMode(DIGITAL_INPUT_SENSOR1, INPUT_PULLUP);
Debouncer debouncer1(DIGITAL_INPUT_SENSOR1, 50);
...
void onPulse1()
{
  Serial.println("pulse1 counted");
  pulseCount1++;
}

debouncer1.subscribe(Debouncer::Edge::FALL, [](const int state) {
    onPulse1();
  });

@simonbaudart did you resolve it? I am experiencing the same.