Door Sensor with ESPHome and 1 ESP32

When we bought our home it came with wired door sensors… for an old alarm system. Given that they are just reed sensor i figured there was a way to get them in to home assistant via ESPHOME.

I have been doing a bit of exploring with WLED and ESP32 boards around house.
After a bit of looking around here I found a few example and tried to figure it out. I was pretty happy when it worked the first time…

I figured I would share here and get some feedback.

5 Doors being monitored off 1 ESP 32.

using a ESP32, provided power via USB, I tied all the reed switch grounds together and the other end of the sensor to different GPIO pins.

Here is some info from the yaml file.

esphome:
  name: esphome-web-d86490
  build_path: .esphome/build/esphome-web-d86490
  platformio_options: {}
  includes: []
  libraries: []
  name_add_mac_suffix: false
esp32:
  board: esp32dev
  framework:
    version: 1.0.6
    source: ~3.10006.0
    platform_version: platformio/espressif32 @ 3.5.0
    type: arduino
  variant: ESP32
logger:
  baud_rate: 115200
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: UART0
  level: DEBUG
  logs: {}
captive_portal: {}
binary_sensor:
- platform: gpio
  pin:
    number: 4
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
    inverted: false
  name: Garage Entry Door
  device_class: door
  filters:
  - delayed_on: 10ms
  disabled_by_default: false
- platform: gpio
  pin:
    number: 15
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
    inverted: false
  name: Rear Balcany Door
  device_class: door
  filters:
  - delayed_on: 10ms
  disabled_by_default: false
- platform: gpio
  pin:
    number: 16
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
    inverted: false
  name: Front Balcany Door
  device_class: door
  filters:
  - delayed_on: 10ms
  disabled_by_default: false
- platform: gpio
  pin:
    number: 17
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
    inverted: false
  name: Front Door
  device_class: door
  filters:
  - delayed_on: 10ms
  disabled_by_default: false
- platform: gpio
  pin:
    number: 18
    mode:
      input: true
      pullup: true
      output: false
      open_drain: false
      pulldown: false
    inverted: false
  name: Back Entry Door
  device_class: door
  filters:
  - delayed_on: 10ms
  disabled_by_default: false

It’s not pretty at the moment. I need to print a case, mount it, and rewire so that it looks better.
I was able to create some automation bases on the state to check it out and turn on a light when the door is in the open state and off when the door is close. So I’m pretty happy its working.
I do wonder if it will last…

3 Likes

Reed switches should last a very long time. Is it the same light that comes on for all doors or different light in each area? Could be bit annoying if light switches off in room as soon as you close the door and leaves you in the dark.
How long are the leads coming from the door sensors to the ESP. I imagine the longer the leads the more chance of the wires picking up random signals and setting off the lights.
I tried a button on a very short wire without the input_pullup and got a disturbing strobe effect from an LED light that would persuade anyone to close any door. What about some pics.
That might help other people try your project.

Question…since ESP seems to consume a lot, batteries seem no option or how do you power this? I donot have cables in my door so chose the zigbee solution

The one light is just in a short hallway that leads to/from the garage. It only triggers on this garage entry door. Yes it can be short on the cycle of on/off, but we are ok with it. There are 5 leads from 5 doors in a 2 story large home. I would say over a hundred(s) feet for the longest lead… I am rather impress it updates extremely fast.

I’ll update with pics as soon as I clean up the wires. but here is the mess of wires at the moment…

Link to the video… IMG_7290.MOV - Google Drive

since all my sensor are wired to a central location I can power with USB outlet.

thanks for this. I was using Konnected on Smartthing and wanted an alternate for HA. I have a model on Thingiverse that i use to mount these on walls. I can attach pictures but this box has enough space for a esp8266 and a relay switch.

1 Like

May i ask. About configuration
mode:
input: true
pullup: true
output: false
open_drain: false
pulldown: false

Ask you set mode
Input to true . Why have to set outut to false
Pullup :true. Why have to set pulldown:false
And also open_drain:false
Are these setting parameters effect input trigger from reed sw?
I setup the same model esp32 you did. To replace old security alarm system. But also add pzem004t to the same esp32 board