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
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?
Suggested board
ESP32-C6-DevKitC-1
- 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
| Item | Quantity | Role and precautions |
|---|---|---|
| ESP32-C6-DevKitC-1 | 1 | Control board (see the box above). |
| Waterproof momentary push button (IP65) | 1 | Normally open contact; a 12 mm metal model holds up outdoors. |
| Passive piezo buzzer | 1 | Passive: it needs a signal to play a tune, unlike an active buzzer that only makes one fixed tone. |
| 2- or 4-core alarm cable | 2 to 10 m | Link between button and board; outdoors choose a UV-resistant cable or protect it with a sleeve. |
Small parts
| Item | Quantity | Role and precautions |
|---|---|---|
| USB-C data cable | 1 | For flashing and power. Charge-only cables do not carry data. |
| USB 5 V power supply (CE/UKCA-marked charger) | 1 | At least 1 A for the board alone; more if peripherals draw power from it. |
| Dupont jumper wires (male-female and female-female) | 1 | One mixed pack covers every prototype. |
| Breadboard | 1 | To test without soldering; replace with a soldered build if you need it permanent. |
| Assorted 1/4 W resistors | 1 | Handy for pull-ups (4.7 kΩ to 10 kΩ) and protection (330 Ω). |
| Heat-shrink tubing | 1 | Insulates solder joints and splices; avoid tape in a permanent build. |
| Vented plastic or 3D-printed enclosure | 1 | Protects 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
- 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.
- 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”.
- 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
- 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.
- Connect the buzzer’s + to GPIO18 and its − to GND.
- 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
- 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.
- 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.
- 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
- Press the button: the buzzer plays the tune, which proves the board has detected the press.
- In Home Assistant open the ESPHome device: “Doorbell button” turns “on” while pressed.
- 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
- 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.
- Run the cable to the board and connect it with a terminal block.
- 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
- 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.
- Trigger: the “Doorbell button” entity turns “on”. Action: notification through the Home Assistant mobile app, with the text you like.
- 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
| Symptom | Fix |
|---|---|
| The buzzer makes no sound | You may have an active buzzer or reversed polarity. Check the + on GPIO18 and try another passive buzzer. |
| Phantom rings | The 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 arrive | Check that the entity changes state, then the notification action and the mobile app service. |
| Tune too loud or too quiet | Set “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.
- Install ESPHome in Home Assistant (Device Builder)Install the add-on, prepare your passwords (secrets) and create the first device
- Flash an ESP32 with ESPHome (USB, drivers, boot mode)First upload over USB, CP210x and CH340 drivers, boot mode
- ESP32 wiring basics: GPIO, 3.3 V and pull-upsWhich pins to avoid, 3.3 V versus 5 V, pull-up resistors and common ground
- ESPHome OTA updates: flash without a cableUpdate the board without a cable, OTA password and recovery if something goes wrong
Other ESP32 projects
- Door and window opening sensor
- Connected garage door
- mmWave presence sensor (LD2410)
- See all ESP32 projects
