Smart home

Smart doorbell ESP32 ESPHome

Wi-Fi doorbell for Home Assistant: button, ESP32-C6, ESPHome, phone notification, no mains wiring. Parts list, GPIO wiring, ESPHome YAML and Home Assistant

Updated · Emmanuel SAUVAGE

  • LevelBeginner
  • Time1–2 h
  • Budgetabout CA$15–30 depending on the seller

Rough estimate, check with your seller: prices vary by shop and period.

Project goal

You will build a connected doorbell: a button at the front door sounds a buzzer, a small electronic speaker, inside the house and at the same time sends a notification to your phone through Home Assistant, the software that gathers your connected devices. The button is a simple low-voltage contact, linked by a small cable to an ESP32, a small electronic board with Wi-Fi.

Why build it

You are alerted even in the garden or the garage. You can silence the bell during a baby’s nap with a “mute” switch, and the same button can also turn on a light or trigger an announcement in the house.

Useful terms for this project: ESP32 (small Wi-Fi board) · ESPHome (prepares the board’s program) · GPIO (the board’s pins) · OTA (update without a USB cable)

Prerequisites

  • Home Assistant with ESPHome, the board placed where Wi-Fi reaches.
  • A push button (normally open contact) suited to outdoors, at least IP44.
  • A low-voltage cable a few metres long between the button and the board (2- or 4-core alarm cable).

Diagrams

Wiring diagram : Smart doorbell
Wiring diagram : Smart doorbellGPIO10 → Push button Contact A; GND → Push button Contact B; GPIO18 → Passive buzzer +; GND → Passive buzzer −ESP32-C6 DevKitC-1Push buttonGPIO10Contact AGNDContact BPassive buzzerGPIO18+GND−Data or signalGround (GND)Control
Principle diagram : Smart doorbell
Principle diagram : Smart doorbellOutdoor button → ESP32-C6 + ESPHome → Home AssistantOutdoor buttonDry contact: ties GPIO10 to GNDLow-voltage cable, a few metresGPIO10 input, GPIO18 outputESP32-C6 + ESPHome50 ms debounce, plays the tune on the buzzer“Doorbell mute” switch2.4 GHz Wi-Fi + encrypted APIHome Assistant“Doorbell button” entityNotification, light, voice announcement

Parts list

This ESP32 board is the base for every project in the series. ESPHome also works with other ESP32 boards: the board-choice guide helps you compare them. Which ESP32 board to choose?

ESP32-C6-DevKitC-1

Suggested board

ESP32-C6-DevKitC-1

check with the seller
  • Wi-Fi 6, Bluetooth 5, Zigbee and Thread (at hardware level)
  • Supported by ESPHome (ESP-IDF framework)
  • USB-C for flashing and power

Watch-outs

  • 2.4 GHz Wi-Fi only
  • Use a USB cable that carries data

Main components

ItemQuantityRole and precautions
ESP32-C6-DevKitC-11Control board (see the box above).
Waterproof momentary push button (IP65)1Normally open contact; a 12 mm metal model holds up outdoors.
Passive piezo buzzer1Passive: it needs a signal to play a tune, unlike an active buzzer that only makes one fixed tone.
2- or 4-core alarm cable2 to 10 mLink between button and board; outdoors choose a UV-resistant cable or protect it with a sleeve.

Small parts

ItemQuantityRole and precautions
USB-C data cable1For flashing and power. Charge-only cables do not carry data.
USB 5 V power supply (CE/UKCA-marked charger)1At least 1 A for the board alone; more if peripherals draw power from it.
Dupont jumper wires (male-female and female-female)1One mixed pack covers every prototype.
Breadboard1To test without soldering; replace with a soldered build if you need it permanent.
Assorted 1/4 W resistors1Handy for pull-ups (4.7 kΩ to 10 kΩ) and protection (330 Ω).
Heat-shrink tubing1Insulates solder joints and splices; avoid tape in a permanent build.
Vented plastic or 3D-printed enclosure1Protects the board; leave a cable gland and vents if the sensor measures air.

Amazon links are affiliate links: the site may earn a commission at no extra cost to you.

Step-by-step build

Step 1. Prepare ESPHome and create the device

  1. In Home Assistant, open the ESPHome Device Builder add-on (see the tutorial “Install ESPHome in Home Assistant (Device Builder)”). ESPHome is the software that turns a simple settings file into the program for your ESP32 board, without you having to write any code.
  2. Open “Secrets” (top right): this file keeps your passwords apart, so you can share your configurations without revealing them. Check that wifi_ssid (the name of your Wi-Fi network), wifi_password, api_encryption_key (the key that encrypts the link with Home Assistant), ota_password (for updates without a cable) and ap_password (for the board’s fallback Wi-Fi network) exist, and add any missing line. A valid API key is a long 32-byte string encoded in base64, which you can generate with “openssl rand -base64 32”.
  3. Click “New device”, name it “sonnette-connectee”, pick ESP32-C6, skip the flash for now, then replace the file content with the YAML from this page (“Edit”). YAML is a configuration file written in plain text: it describes, line by line, what the board must do.

What you should see: The file opens in the editor with syntax highlighting and no red underline.

Check: The “Validate” action (⋮ menu) answers “Configuration is valid”.

Step 2. Wire the button and the buzzer

  1. With the USB power unplugged, connect one of the button’s two contacts to GPIO10, one of the metal pins lined up along the edge of the board (GPIO means “general purpose input output”), and the other contact to GND, the ground; the direction does not matter, because a button simply closes a circuit.
  2. Connect the buzzer’s + to GPIO18 and its − to GND.
  3. For a test, plug the button and buzzer on a breadboard before the final wiring.

What you should see: Nothing is powered apart from the board’s USB.

Check: The button is between GPIO10 and GND, the buzzer between GPIO18 and GND.

Step 3. Flash the board and add it to Home Assistant

  1. Connect the board to your computer with the USB-C data cable: “flashing” means writing the program into the board’s memory, and this first write must be done over a cable. The board can already be wired or sitting on the breadboard, but any external peripheral with its own power supply must stay switched off.
  2. In ESPHome click “Install”, then “Plug into this computer” (Chrome or Edge over HTTPS) or “Manual download” and upload the file with ESPHome Web (web.esphome.io). If the port is missing, follow the flashing tutorial.
  3. After the reboot open Settings → Devices & services: the ESPHome device is discovered; click “Configure” and paste the API encryption key.

What you should see: The “Logs” show the Wi-Fi connection and then “Successfully connected to Home Assistant”.

Check: The device appears under Devices & services → ESPHome with its entities; later updates need no cable and go over Wi-Fi (this is OTA, “Over The Air”).

Step 4. Test the ring and the entity

  1. Press the button: the buzzer plays the tune, which proves the board has detected the press.
  2. In Home Assistant open the ESPHome device: “Doorbell button” turns “on” while pressed.
  3. Turn on “Doorbell mute” then press: the buzzer stays silent while the entity still reacts.

What you should see: A short press gives a single tune, with no stray repeats.

Check: If the buzzer does not play, check that it is passive and that GPIO18 is on its +.

Step 5. Install the button at the door

  1. Fix the button on the door frame, out of direct rain, and make a cable loop pointing down: water running along the cable will drip off at the lowest point instead of getting into the button.
  2. Run the cable to the board and connect it with a terminal block.
  3. Press at the door from outside and check that the buzzer plays.

What you should see: No unwanted ringing after installation, even in damp weather.

Check: If the button triggers by itself, shorten the cable or add a 10 kΩ external pull-up between GPIO10 and 3V3.

Step 6. Create the notification automation

  1. An automation is an “if… then…” rule that Home Assistant applies by itself: here, if someone rings, your phone receives a message. Open Settings → Automations & scenes → Create automation.
  2. Trigger: the “Doorbell button” entity turns “on”. Action: notification through the Home Assistant mobile app, with the text you like.
  3. If you wish, add an action that turns on a light or plays a voice announcement on a connected speaker.

What you should see: A notification reaches the phone a few seconds after the press.

Check: Test with the phone on mobile data: the notification must also arrive off Wi-Fi if remote access is configured.

ESPHome code (YAML)

YAML is a configuration file written in plain text: it tells ESPHome what the board must do. Paste this one into ESPHome after creating the device. It targets an ESP32-C6 board; values to personalise are marked with “CHANGE” comments.

esphome:
  name: sonnette-connectee
  friendly_name: Smart doorbell

esp32:
  board: esp32-c6-devkitc-1   # XIAO ESP32C6: use board: seeed_xiao_esp32c6
  framework:
    type: esp-idf             # required for ESP32-C6

logger:                       # serial logs, also visible over Wi-Fi

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid       # 2.4 GHz network only
  password: !secret wifi_password
  ap:                           # fallback hotspot if the Wi-Fi is unreachable
    ssid: "sonnette-connectee fallback"
    password: !secret ap_password

captive_portal:

output:
  - platform: ledc
    pin: GPIO18                  # passive buzzer, driven by PWM
    id: buzzer_out

rtttl:
  output: buzzer_out
  id: doorbell_tone
  gain: 0.6                      # volume, from 0.0 to 1.0

switch:
  - platform: template
    name: "Doorbell mute"
    id: doorbell_mute
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF

binary_sensor:
  - platform: gpio
    name: "Doorbell button"
    id: doorbell_button
    pin:
      number: GPIO10
      mode: INPUT_PULLUP         # button between GPIO10 and GND
      inverted: true             # pressed = ON
    filters:
      - delayed_on: 50ms         # ignores contact bounce and brief noise
      - delayed_off: 50ms
    on_press:
      - if:
          condition:
            switch.is_off: doorbell_mute
          then:
            - rtttl.play: "doorbell:d=4,o=5,b=160:e6,c6,e6,2c6"

  - platform: status
    name: "Doorbell status"

sensor:
  - platform: wifi_signal
    name: "WiFi signal"
    update_interval: 120s
    entity_category: diagnostic

YAML comments are in English, as in the ESPHome documentation. This code has not been run on your hardware: use “Validate” before flashing and adjust pins and names.

Home Assistant integration

  • The “Doorbell button” entity is a plain binary sensor: any automation can hook into it (notification, light, scene).
  • The “Doorbell mute” switch appears on the dashboard; it silences the local ring while keeping the notification.
  • To see the visitor, add an existing IP camera to the automation: Home Assistant can attach a camera image to the notification.

Common problems and troubleshooting

SymptomFix
The buzzer makes no soundYou may have an active buzzer or reversed polarity. Check the + on GPIO18 and try another passive buzzer.
Phantom ringsThe cable is long or picks up noise. Add a 10 kΩ external pull-up to 3V3, keep the cable away from mains lines and raise the delayed_on filter.
The notification does not arriveCheck that the entity changes state, then the notification action and the mobile app service.
Tune too loud or too quietSet “gain” between 0.0 and 1.0 in the YAML, then reinstall over OTA.

FAQ

Can I reuse my existing doorbell?

Never connect it directly to the ESP32. An isolated input module made for it, or an electrician, is required.

Is it a video doorbell?

No: this project adds neither image nor sound. You can add an IP camera that Home Assistant attaches to the notification.

Can the button be wireless?

Not in this build, which uses a cable. A commercial Zigbee wireless button would be an alternative.

Related tutorials

These step-by-step guides explain the gestures common to every project in the series.

Other ESP32 projects

Sources and documentation

Cette page vous a-t-elle été utile ?

Have a question about this guide or need advice? Ask us here

Torn between two models or stuck on a build? Drop us a line and we will get back to you by email.