Reed Switch Wiring and ESPHome Setup

Hello Community - I’m trying to setup a reed switch to track water meter usage. I thought this was going to be a super simple project, but nothing ever is.

I’m a noob, but I’ve been reading for days on this topic. Here is what I have:

  • 2-wire reed switch (I confirmed it works using a continuity tester and a magnet)
  • ESP32 Mini Board

I have created the following ESPHome code:

# Reed switch between GPIO and GND
sensor:
  - platform: pulse_counter
    unit_of_measurement: 'Gallons'
    name: 'Water Meter'
    pin:
      number: GPIO22
      inverted: true
      mode:
        input: true
        pullup: true

I have tried both GPIO21 and GPIO22. It is my understand that both of these should have pullup functionality. I have also confirmed that both of these GPIOs work when I connect them to a ESPHome LED Switch.

My wiring is Black Wire from Reed switch to GND/TXD on ESP32 board; Red wire from Reed switch to GPIO22.

When I pass a magnet over the reed switch nothing trips a count in HA or the ESPHome logs. Is there something I am missing in my setup?

Also, as a side question, can you help me understand why I have multiple designations for each pin on the mini board? For example my board shows IO25 and IO22 for the same pin. When I setup up a simple LED light switch, only GPIO22 seems to work to trigger the on/off switch.

Screenshot from 2024-11-18 12-24-35

You have two columns of through-holes on each aide. My assumption is that the left label applies to the left hole and the right label to the right hole. This may likely be your root issue as well, as you may not actually be connecting to the pins you think you are.

I can’t help you with your reed switch but the board has two rows of pins on each side so you have two labels.

8248a35c21a5b7d08a24f6c70ed8474d3b9f039c

If you are connected to GPIO25 just change your config. It will be easier than de-soldering / re-soldering.

1 Like

This is one of those hands on face learning moments. That totally makes sense. I think/hope that my issue is that I am connected to GPIO22 but not to ground. Instead I am connected to TXD.

After changing my setup and getting my GRD to a ‘real’ ground pin, it now works

Thanks to everyone for your help!!