Unterstading pulse reading in esphome

I’m new to esphome and trying to get a reading from an anemometer. I failed by connecting it to the esp32 and now I’m experimenting with pulse_meter and pulse_counter to understand how they work but the results confuses me:

Experimental setup on my ESP32: I have one cable connected to 3.3v and one cable connected to GPIO23 (confirmed with an LED).

This is my pulse_counter code:

sensor:
  - platform: pulse_counter
    pin: GPIO23
    name: "windspeed"
    update_interval: 5s

Action: Repeatably tipping the two cables to each other
Log:
[D][sensor:125]: 'windspeed': Sending state 0.00000 pulses/min with 2 decimals of accuracy
Expected outcome: Log shows number of times the cables got connected.

This is my pulse_meter code:

sensor:
  - platform: pulse_meter
    pin: GPIO23
    name: "windspeed"

Action: Both cables are not connected:

Log:

[09:04:09][D][sensor:125]: 'windspeed': Sending state 3000.00000 pulses/min with 2 decimals of accuracy
[09:04:09][D][sensor:125]: 'windspeed': Sending state 3157.89478 pulses/min with 2 decimals of accuracy
[09:04:09][D][sensor:125]: 'windspeed': Sending state 5454.54541 pulses/min with 2 decimals of accuracy
[09:04:09][D][sensor:125]: 'windspeed': Sending state 2142.85718 pulses/min with 2 decimals of accuracy
[09:04:09][D][sensor:125]: 'windspeed': Sending state 3000.00000 pulses/min with 2 decimals of accuracy

Action: Both cables are connected:
Log:
Nothing
Expected outcome: Log shows only reading if I keep connecting the cables.

Obviously I do not understand the two pulse components. My anemometer is sending short pulses when rotating. It was working well for a couple of years connected to RaspPi with some custom code it should get replaced now with the ESP32.

Any hints?

How are the wires connected? are you using a pull up / pull down resistor?
A microcontroller will hate floating inputs and those can result in weird behavior.

The wires are directly connected to the pins. I assumed esphome is using the internal pull-up/pull-down resistors.

I added an (external) pull-down resistor and tried the pulse_meter code. It works! I only see pulses when I do expect them…

You know what i am going to say :stuck_out_tongue:
Glad it works now