Smart home doorbell with WiFi, secure detection and mobile alerts

  • Safe 230V detection with optocoupler and separation between power and logic.
  • ESP-01, 3,3V power supply (LM317T) and 3D case assembly for a clean project.
  • Interrupts, MQTT and OpenHAB for reliable mobile alerts and SMS option.

smart doorbell

Ding-dong! I'm sure you also have a classic doorbell at home that does its job, but we don't always realize that someone is ringing: it can catch us in a lost corner, with the vacuum cleaner running at full speed, with headphones on or simply with so much noise around that we miss the delivery person's notification. The idea of ​​turning that doorbell into a smart home doorbell Having it notify you on your mobile (and on your watch, if you wear one) is a great way to avoid missing deliveries or visits again.

Furthermore, some people want to go a step further and request that the doorbell make its usual sound. light up an indicator LED and, if possible, send a text message when someone presses the button. This raises reasonable questions: should we use two microcontrollers connected via WiFi (for example, two ESP32s) or opt for something simpler like a radio frequency link? Should we utilize the existing doorbell with its 230V supply or build a completely new one? In the following lines, I'll explain the different approaches, components, safe assembly, and a software proposal using MQTT, OpenHAB and Pushbulletso that the project turns out neat, beautiful and functional without complicating your life.

Architecture: from two MCUs to RF, via WiFi

When considering the design, the first thing that comes to mind is using two MCUs on the same home network: one module inside, one outside, communicating via WiFi. It works, yes, but it can be a bit excessive and expensive. If you use two ESP32s just for one doorbell, the real objective is very basic: an external push button that triggers the internal logic, which then does everything else (sound, LED, mobile notification, even SMS).

A lighter alternative is to place a simple radio frequency transmitter and receiver between the outer button and the inner microcontroller. The beauty is that the button side doesn't need a full MCU: with a cheap RF moduleWith a battery and a well-sized circuit, you send the signal when it's pressed. Inside the house, a WiFi-enabled MCU receives the alert from the RF receiver and executes the rest: sound the "ding-dong," activate an LED, send the notification, and, if desired, trigger SMS sending through an external service.

If you prefer to keep the existing wiring and take advantage of the 230V doorbell If you already have that, there's another great approach: detect the presence of voltage when it rings. That detection, performed with galvanic isolation, feeds the logic of a WiFi microcontroller that publishes the event and notifies you. This way you don't replace your doorbellYou "wake him up".

For users who are hesitant about DIY projects, there's also the option of buying an all-in-one tool. They're available on the market. wireless smart visual intercoms with IP65 protection and a 1080P camera that functions as a video doorbell and two-way talk device. Some stores even include "Share" controls on the product page, and more than one offers forms for “Have you seen a lower price?” where they ask you to indicate if it was in physical store, province and other details to study whether they equal the cost. That is, There are very comprehensive commercial solutionsBut if you like tinkering, a home improvement project will be cheaper and custom-made.

smart doorbell project

Safely detect 230V: optocoupler to the rescue

Many conventional doorbells are powered by 230V only while someone is pressing the button. The key to “listening” to that event without risks It involves completely isolating the power section from the logic section. This is where the optocouplers: devices that transmit the signal by means of light between two separate circuits, ensuring that there is no direct electrical connection between the mains and your 3,3V electronics.

To make life easier, you can buy a plaque already made It detects the 230V and provides a safe output for the microcontroller. These boards typically include the appropriate optocoupler and resistor, protecting your MCU. It is a fast and robust solution If you don't want to design it from scratch. If you enjoy building, the other option is to replicate that scheme yourself with a handful of components easy-to-find, maintaining the philosophy of physical separation between power and logic.

Pay attention to the layout and distances: it's advisable to leave a generous separation on the board between the area where the 230V flows and the area that powers the microcontroller. If you are working on a perforated board, leave wide gaps and, If you can, encapsulate everything. in a cleverly designed box to prevent unwanted touches. Optocouplers, by their very nature, add a layer of tranquility that allows you to sleep soundly.

Another important element is the power supply: the microcontroller we're going to use operates at 3,3 VIf you don't have a 3,3V source available, you can step down from 5V using a regulator. LM317Tadjusting it correctly to deliver a stable 3,3V. This combination (5V power supply + regulator) is very common in home projects. cheap and effective.

smart doorbell installation

Practical hardware: ESP-01, 3D case and wiring harness

To provide WiFi connectivity to the system, a classic and well-known candidate is the ESP-01It's small, affordable, easy to program, and above all, enough for a doorbellCompared to an ESP32, which is a beast for bigger projects, here the ESP-01 more than covers event reading, network connection, MQTT publishing and triggering notifications.

In the physical assembly, it can be interesting to enclose everything in a 3D printed box to make it compact and secure. When the ESP-01 circuit board and the power supply board are combined (plus a space for a terminal block), Sometimes the sum fits almost perfectly. with the space of a traditional "ding-dong" doorbell. This allows you to place the electronics close to the chime itself and maintain the look and feel of your home without any strange contraptions on display.

The wiring is also tricky. It's best to take it to a... clema The doorbell phase, the phase for powering the electronics (which must be separate so that the microphone always has power, even if the doorbell is not pressed), and the neutralThis way, you can detect when power is supplied to the doorbell and, at the same time, keep the smart system always online to publish events and send notifications. Note the regulation: everything in its placeand with physical separation between power and logic.

For DIY fans, setting up the circuit in a perforated plate It works great, as long as you respect social distancing. Some promise that one day they'll switch to custom PCBs, but in the meantime, a well-made perfboard... It's great!If you'd like to document the design, you can keep the schematic in your favorite tool (for example, in an EAGLE file), which then makes it easier to share and review.

smart doorbell electronics

Software and notifications: interrupts, MQTT, OpenHAB and Pushbullet

Let's move on to the "brain". In the firmware section for the ESP-01, an effective way to detect the event is to use a flank interruptionOne practical detail: defining the pin 3 (the RX pin of the serial port) as an interrupt pin, so that when the detector (or optical sensor) indicates the presence of voltage, a routine is triggered that marks the state of the doorbell.

The typical configuration in many examples uses a line like this: attachInterrupt(digitalPinToInterrupt(sensePin), onDoorbellStateChange, FALLING);The routine, decorated with ICACHE_RAM_ATTR In ESP8266/ESP-01 firmware, it could be something like: void ICACHE_RAM_ATTR onDoorbellStateChange() { lastTrueState = millis(); doorbellState = true; }This saves the moment of the shot and sets the "someone has called" status to true.

In the main loop, after a reasonable amount of time, the marker is reset to allow new alerts. This is where a temporary check comes into play. if (doorbellState && (now – lastTrueState) > 5000) { doorbellState = false; isStateSent = false; }With this, if 5 seconds have passed since the last call, the event is considered closed and notifications can be sent again if someone presses it again. This way you avoid spam ads by a single long press or bounces.

To integrate with home automation and smart home standards, MQTT It's incredibly convenient. You can set up your own broker and integrate it into... Open HABwhere you will create a "Thing" and its corresponding "Item" that represents the doorbell's state (for example, OFF/ON). From there, you configure the notifications with your preferred service: Pushbullet It's a classic, and you trigger the alert with a rule that goes off when the item changes. OFF to ON.

The skeleton of that rule in OpenHAB could look like this: rule «RuleName» when ItemItemName changed from OFF to ON then val actions = getActions(«pushbullet», «ItemNamePushbulletBot») if (actions !== null) { actions.sendPushbulletNote(«Front doorbell», «Front doorbell», «Someone is knocking on the front door») } endIn simpler terms: as soon as the Item turns ON, you shoot a note to your devices. If you need SMS, you can swap Pushbullet for one. SMS service or through a gateway that has binding available on your home automation platform.

For those who prefer not to touch the original doorbell and want to view it on their mobile phone, remember that there are similar solutions on the market. wireless video doorbell with a 1080P camera and IP65 protection rating. These offer a "factory-installed" visual intercom and, in many stores, even include "" buttonsShare"on the form and the famous form of “Have you found a lower price?” to maintain competitive prices; they may even ask if you saw it in a (physical) store and the province to evaluate the application. They are a convenient alternativealthough in cost they don't usually compete with a well-tuned DIY assembly.

smart doorbell software

Another practical point about the software: it's advisable that the device maintains the stable WiFi connection and that it implements automatic reconnections to the MQTT broker if it goes down. ESPs typically include a "reconnect if there is no link" routine, and monitor with a timer It shouldn't get stuck trying to reconnect endlessly. A software watchdog can save you from more than one tight spot in the real world.

For the indicator LED, you can make it blink in time with the event (for example, for 5 seconds after firing) and then turn off. If you want a finer touch, use a blink with fade by PWM indicating "call in progress" and a brief steady light for “call logged”. These visual cues, while not essential, are appreciated when you don't have your mobile phone handy.

Those considering sending SMS messages should remember that there are services and APIs that allow you to send messages with a simple HTTP call from your MCU or, better yet, from your home automation serverThis reduces the load on the microcontroller and centralizes the logic (For example, only send SMS messages if the house is in "away" mode). Also, SMS messages usually have a cost per transmission, so it's a good idea to set a small anti-spam rule that avoids sending more than one message every X minutes.

Incidentally, if you integrate everything with OpenHAB (or similar platforms), you will separate what is “discovery and publishing” (MCU) from what is “automation and notification” (server). This division of responsibilities This makes the system easier to maintain: the microcontroller focuses on a simple task, and the more flexible server manages notifications, filters, rules, and Historical records calls.

Once wired and tested on the table, it's time to install: you may need to run a new stage all the way to the doorbell to provide continuous power to the smart device. In many homes, the existing conduit allows for this, requiring only a minor modification to the nearest junction box. It is extremely important to work safely. Short voltage, identify conductorsCheck the regulations and, if you have any doubts, call a professional.

If you feel you're missing an "extra," the next step could be to measure how many times you press the button (basic telemetry), use a PIR motion sensor, Expose metrics to your system (for example, via MQTT to a time series database) or even record a clip with an IP camera when the doorbell is triggered. It's not strictly part of the original project, but automation brings these benefits.

Regarding the finish, try to make the 3D printed box Make sure it's well ventilated so the regulator (if you're using an LM317T) doesn't overheat. A small heatsink and leaving space between components will help. Also, labeling the inside "ringer live," "power live," and "neutral" will help. will facilitate future reviews or expansions without having to guess anything when you return to the project months later.

Returning to the initial debate (two MCUs vs RF), if you're concerned about power consumption at the external push button and simplify as much as possibleThe RF + MCU combo inside is a plus: the external transmitter can be minimal and low-power, and you keep everything "ready" inside, with a stable power supply. If you prefer to avoid the radio link and already have wiring to the doorbell230V detection with opto and a single MCU is straightforward, robust, and clean.

Finally, a couple of good practices: document the schematic (even if it's just a photo of the prototype with annotations), Upload the code to your repository and add a README file with the pinout. Small details like indicating that the pin 3 (RX) It's used as an interrupt to prevent surprises if someone, or you yourself, decides to activate the serial port without looking. And if you share the project, even betterOthers will be able to replicate it, improve it, or give you ideas.

It is clear that there is a path for both the maker who wants to keep their "ding-dong" and receive alerts, and for those who prefer a complete commercial system with camera and IP65 certification. If you're up for DIYThe combination of a secure detector, ESP-01, 3,3V power supply with LM317T, 3D enclosure, edge triggering, MQTT, OpenHAB, and Pushbullet gives you a reliable, expandable, and, above all, customized smart doorbell for your home, with the possibility of Add SMS or any other channel without redoing the invention.

Arduino board compatible with sensors for Arduino
Related article:
Sensors for Arduino, a great combination for novice users