Build a Apple HomeKit Doorbell Chime using an ESP32 and HomeSpan
- Jan 25
- 3 min read
Updated: May 20
Ok so I had a problem, I have a freestanding workshop/studio apartment in my backyard, and I wanted to be able to hear an alert when the main house doorbell rings. My wife is not keen to have doorbell alerts on her iPhone, so I needed to engaged my super nerd skills.
I already have a Reolink POE Smart DoorBell connected to CCTV Network Video Recorder (NVR) that talks to Apple HomeKit via my Linux Scrypted Server. I know this sounds complicated but it works great and has not had a problem since it set it up over 2 years ago. I really like Apple HomeKit but I find the Apple Homepod Mini is unreliable when used as a DoorBell Chime so I needed to come up with a better solution.
Tech Nerd Challenge:
Create a WIFI connected doorbell chime that will reliably activate when someone rings the front smart doorbell.
Apple HomeKit, a ESP32-S2 Microcontroller and the HomeSpan Library to the rescue.
Below I will provide an overview of building the doorbell and the solutions to the issues I encountered along the way. I hope this helps if you are a super nerd like me.
Circuit Diagram
After doing some research and testing on a breadboard I came up with the circuit design below. You will see I have used an old 220v doorbell chime from a previous project. You should know I have a background in electrical engineering, so I was very comfortable working with higher voltage circuits safely. You should use lower voltage circuits components (e.g. 12 Volt) or ask a qualified electrician to help you!!!

Key Components:
Mechanical Wired Doorbell | |
Double Sided PCB Board Prototype | |
2.54mm Pitch 8-Pin Double Row Straight Connector Female Pin Header Strip PCB Board Socket | |
eMagTech 2pcs XH-M299 Switching Power Module Mini AC-DC Converter Module AC to DC | |
ESP32-S2 Mini, WIFI, USB Type C, WIFI Development Board, 4MB FLASH 2MB PSRAM | |
1 Channel 12V Relay Module with Optocoupler Isolation Expanding Board | |
5mm LED Light Emitting Diode |
Physical Construction Tips:
Start on a breadboard to test your components and software before you get out the soldiering iron.
Careful layout planning was critical to get all the components to fit in the tight space under the Doorbell cover. You do not want to have your components rattling around especially if you are wiring higher voltage circuits.
Take time watching YouTube videos on soldering on circuit boards if you are not very experienced.
When working with Microcontrollers I like to user header strips so its easy to upgrade or replace key components if they fail.


Download and install the latest version of the Arduino Integrated Development Environment (IDE) https://www.arduino.cc/en/software

Connecting to your Microcontroller
There are many clones of popular ESP32 Microcontrollers and unfortunately, they can be very inconsistent even when the look almost identical. In this circuit I was using the Wemos v1.0.0.0 ESP-32_S2 and did not have any issues. I did have another clone ESP-32_S2 where the WIFI did not work at all.
If your computer does not connect a serial port when you connect a new ESP-32_S2 hold down Button 0 while you hold down the Reset Button for 2 seconds and release both buttons and the port should appear in the Ardunio IDE. You may also need to install a USB to serial driver if you computer requires it.
I found making the following changes in the Arduino IDE when uploading my code were required to ensure that the Microcontroller behaved as needed.

The HomeSpan Coding Implementation
HomeSpan was developed and continues to be maintained and supported by Gregg Berman (Copyright (c) 2020-2024 Gregg E. Berman). It is robust, reliable and has excellent documentation / code examples all available via this link (https://github.com/HomeSpan/HomeSpan).
I do not consider myself an expert coder, but it was easy to make some changes to the HomeSpan “08 Bridges” Code Example. I like setting up my HomeSpan projects in HomeKit as bridges because I the Microcontrollers can support many purposes, and I often add additional functions like temperature sensors and motion detectors.
Main Sketch
#include "HomeSpan.h"
#include "DEV_LED.h"
void setup() {
homeSpan.setStatusPin(16);
homeSpan.setPairingCode("11122333");
homeSpan.begin(Category::Bridges,”MyESP32S2");
homeSpan.setWifiCredentials(”YOUR_SSID", ”WIFIPasscode");
homeSpan.setConnectionTimes(15,60,3);
new SpanAccessory();
new Service::AccessoryInformation();
new Characteristic::Identify();
new Characteristic::Name("DoorBell Chime");
new DEV_DoorChime(18);
} // end of setup()
void loop(){
homeSpan.poll();
} // end of loop()
Include DEV_LED.H
I replaced the “boolean update” section with this code make the doorbell chime multiple times.
boolean update(){
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
delay(200);
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
delay(200);
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
delay(200);
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
return(true);} // update
Upload you sketch and power it up
Once you power it up the Status LED will tell you if it connects to your Wifi. https://github.com/HomeSpan/HomeSpan/blob/master/docs/UserGuide.md#getting-started
Pairing with your iPhone
Make sure your iPhone is connected to the same WiFi network as your Doorbell Chime.
Click on the "Add Accessory" option in HomeKit
Select "More Options...."
You should see the bridge name appear "MyESP32S2"
Enter the Pairing Code ("11122333") when prompted. Do not be worried if some "-" characters are added in by your iPhone.
Add the "DoorBell Chime" Accessory

