How to Make Your Main Door Smart

by efratomer in Circuits > Microcontrollers

1529 Views, 5 Favorites, 0 Comments

How to Make Your Main Door Smart

20210909_085900.jpg
20210909_085851.jpg
20210906_144713.jpg

Are you familiar with not being sure whether or not you've locked your home or not? Or being afraid to have someone ring the door bell at night and wake up the kids? If so, this can be solved with a smart door!


Follow along the steps for transforming your main door smart.

The project has the following features:

  • Detect the main door state:
  • Open
  • Closed
  • Closed & Locked
  • Notify when door-bell is ringing
  • Door-bell silent mode (i.e. at night)
  • Use door-bell as an intruder alarm

This project is part of making my whole house smart and integrates with some already existing setups:

  • Home Assistant - Open source home automation that puts local control and privacy first
  • ESPHome - A system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems

Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipments and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This projects must be done according to your country's local law.

Supplies

Compnents:

  1. Protoboard
  2. Wemos D1 Mini (ESP8266 MCU)
  3. 5V Relay
  4. Step down LDO 15-5v to 5v
  5. Reed switch
  6. Small magnet (should be similar to your door lock bar size, as thin as possible)

Tools:

  1. Ferrule Crimping Tool Kit

Understand Existing Door Bell

20210821_161929.jpg

Analyze your existing door bell, understand how it works and where is the existing bell button is connected.

My bell seems to operate on an 220v AC input which then transforms to 7.5v AC. The 7.5v AC current is being connected through the button triggers to a magnetic shaft which will run back and forth while hitting a metal plate which will make the ring sound (as long as the button is pressed). The shaft movement is done due to AC characteristics.


Every door bell can be different, please make sure you fully understand how it works and how to bypass it using an external controller before moving on.

Position the Sensors

InkedInked20210921_205717_LI.jpg
Inked20210921_205812_LI.jpg
Inked20210921_205744_LI.jpg
20210906_144708.jpg
20210906_142911.jpg

The door open sensor is just a magnetic sensor which is not too fancy and there is no much to talk about it.

For the lock sensor, position the small magnet on the lock bar and verify that the door can still be closed and locked while the magnet fits inside the lock's bar hole in the door frame.

Drill a small hole to fit 2 small wires through the door frame.

Push the reed switch inside the door's frame hole where the lock bar is inserted and pass it's wires through the hole you just drilled.

Test the reed switch and magnet setup to verify it is indeed sensing the magnet only when door is locked, This can be done with a multimeter.

After you feel confident enough, glue the magnet on the lock bar and glue the reed switch wires around the door frame (which will ensure the reed switch is also fixed properly).

Plan Main Board

20210909_075447.jpg
20210909_075457.jpg
Screenshot 2021-09-21 210937.jpg
20210821_222214.jpg
20210914_090248.jpg
Schematic_main door_2021-09-21.png

The plan is to position an MCU (WeMos D1 Mini) inside the bell case together with some peripherals. It is obviously not going to fit the current bell case so you should make an extension to the case so everything will fit inside (my STL attached).

The main board should support:

  • Wemos D1 mini MCU
  • 1 voltage input - 12v
  • 3 inputs - door open, door lock, bell button
  • 1 relay output - bell ring
  • 5v LDO
  • Some resistors

(See schematics)

Software

Screenshot 2021-09-21 153420.png

Below you can find my ESPHome configuration file:

Bell ring button will make the bell ring using the relay by software (unless bell button is set as disabled).

binary_sensor:
  - platform: gpio
    pin:
      number: D2
    name: "Main door lock"
    device_class: lock
  - platform: gpio
    pin:
      number: D1
    name: "Main door open"
    device_class: door
  - platform: gpio # Functional only when bell_external off
    id: btn_bell
    name: "Main door bell button"
    pin:
      number: D3
      inverted: true
    filters:
      - delayed_on: 50ms
    on_press:
      then:
        if:
          condition:
            - switch.is_off: bell_external
            - switch.is_on: btn_bell_enable
          then:
            - switch.turn_on: bell_relay
    on_release:
      then:
        if:
          condition:
            - switch.is_off: bell_external
          then:
            - switch.turn_off: bell_relay

switch:
  - platform: gpio
    id: bell_relay
    pin: D7
    restore_mode: ALWAYS_OFF
    
  - platform: template
    name: "Main door bell"
    id: bell_external
    turn_on_action:
      - switch.turn_on: bell_relay
    turn_off_action:
      - switch.turn_off: bell_relay
      
  - platform: template
    name: "Main door bell button enable"
    id: btn_bell_enable
    restore_state: true
    turn_on_action:
      - switch.template.publish:
          id: btn_bell_enable
          state: ON
    turn_off_action:
      - switch.template.publish:
          id: btn_bell_enable
          state: OFF

esphome:
  name: main-door
  platform: ESP8266
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: <YOUR_OTA_PASSWORD>

wifi:
  ssid: <YOUR_WIFI_SSID>
  password: <YOUR_WIFI_PASSWORD>

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Main-Door Fallback Hotspot"
    password: <YOUR_FALLBACK_PASSWORD>

captive_portal:


Home Assistant - Door lock verify automation:

This automation will notify my phone if the door is still unlocked (for 5 consecutive minutes) between 10PM to 7AM.

alias: Security - Door lock verify
description: ''
trigger:
  - platform: time_pattern
    seconds: '00'
condition:
  - condition: time
    after: '22:00'
    before: '07:00'
  - condition: state
    entity_id: binary_sensor.main_door_lock
    state: 'on'
    for: '00:05:00'
action:
  - service: notify.omer
    data:
      message: Door is still unlocked!
mode: single


Home Assistant - Door bell notify automation:

This automation will notify my phone every time the bell ring button was pushed.

alias: Security - Main door bell notify
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.main_door_bell_button
    from: 'off'
    to: 'on'
condition: []
action:
  - service: notify.omer
    data:
      message: Door bell button was detected
mode: single