Door contact / reed switch

Hi,

I have a doorcontact connected to my nodemcuv2, but I have issue’s with creating the yaml code
Now I have this

esphome:
  name: nodemcu21
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: 'ssid'
  password: 'password'

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      mode: INPUT_PULLDOWN_16
      inverted: True
    name: "garagedeur"
    device_class: door
  - platform: gpio

But what every I the door is always closed

INPUT_PULLDOWN_16 is only for GPIO16 from what I read here: https://esphome.io/guides/configuration-types.html

1 Like

Hi!
Did you get the reed switch to work with ESPhome?
I wrote some code for the NodeMCU that work with a reed switch that connected a GPIO pin with GND but I would like to move that over to ESPhome for comfort reasons.

What pins did you connect the reed switch to?

This was the code i used, this worked perfectly for me i used most of my Gpio’s for a 5 window setup

'binary_sensor:

  • platform: gpio
    pin:
    number: D1
    mode: INPUT_PULLUP
    name: “Back Door”
    device_class: door’
3 Likes

What pins did you use? I have 7 reed switches and wonder how to connect them.

They have a similar page for esp32.

Sorry, but I do not understand what it means. For example:

    GPIO16: pin is high at BOOT
    GPIO0: boot failure if pulled LOW
    GPIO2: pin is high on BOOT, boot failure if pulled LOW
    GPIO15: boot failure if pulled HIGH
    GPIO3: pin is high at BOOT
    GPIO1: pin is high at BOOT, boot failure if pulled LOW
    GPIO10: pin is high at BOOT
    GPIO9: pin is high at BOOT

Some of them say that boot will fail if pulled LOW or pulled HIGH. I do not know what it means. Does it matter that some com high on BOOT? Does it matter if I use reed switches? Maybe it is for something else.

Can you please tell me what pins can I use?

Well you can see that @Cable101 used D1, although s/he doesn’t say which board.

Are you wanting to put 7 sensors on one esp8266?

Yes, one one NodeMCU

Or I can get this one. There is a picture or pinout: https://www.amazon.com/KeeYees-Internet-Development-Wireless-Compatible/dp/B07HF44GBT/ref=sr_1_3?keywords=nodemcu&qid=1579230644&sr=8-3

I would go for the pins labelled OK for input. There are 5 on the page I pointed you to.

I am not enough of an expert to know if you can squeeze more out of the esp8266. However there are many more on an esp32.

I’m just throwing this out there: are you certain that the reed switch is working?

Depending on the kind, the magnet is either pulling two tiny pieces of metal together, or pushing them apart. Either way, because this is a mechanical switch, there will be a very small audible click when the magnet is brought close to the reed, even when there is no power to the circuit.

Test this first, before you look for a software issue. Not all reed switches are made to the same standard.

Are you talking about this? https://www.amazon.com/MELIFE-Development-Dual-Mode-Microcontroller-Integrated/dp/B07Q576VWZ/ref=sr_1_3?crid=6Z986R89MN01&keywords=esp32&qid=1579268699&sprefix=esp32%2Caps%2C328&sr=8-3

Which pins could I use with this board?

@DeeBeeKay, I do not have it yet, I want to set it up and wonder what can I use for this.

Yes that is an esp32 board. Go to the random nerd page I posted earlier and folliw the link to the esp32 page.

Thank you for your reply, but they are not the same. The nerd page shows the board with 18 pins on each side, but the one that is on Amazon has 15 pins on each side.

It is not clear to me what pins can I use.

The pins are labelled in the Amazon ad. Perhaps you missed this part of the esp32 page I pointed you to

Note: not all GPIOs are accessible in all development boards, but each specific GPIO works in the same way regardless of the development board you’re using.

@nickrout, I see that pins are labeled, but there is something else after GPIO signs and I do not know if I can use those pins, for example,
image
What does it mean when the pin marked ADC0? Can I use it? Can I use pins that after ACDx have sign TOUCHx? I do not know what TOUCH means.
Some of them have VSPxxxxx or VPSTxxx. Can I use those?
I appreciate you including the link and I tried to read that article because I like to learn instead of just follow, but it still not clear to me and I want to be sure that I connect correct pins.

If you don’t know what touch means, you have not read the article.

Please point me where this article has word TOUCH.

That is the esp8266 page, we are now discussing the esp32 page. https://randomnerdtutorials.com/esp32-pinout-reference-gpios/