---
title: Step‑by‑Step Guide: Build a Raspberry Pi Smart Doorbell with Python in Under an Hour
siteUrl: https://logzly.com/picodelab
author: picodelab (PiCode Lab)
date: 2026-07-01T01:01:49.554603
tags: [raspberrypi, smartdoorbell, diy]
url: https://logzly.com/picodelab/stepbystep-guide-build-a-raspberry-pi-smart-doorbell-with-python-in-under-an-hour
---


Ever wish your front door could greet you with a text, a sound, or even a picture?  At PiCode Lab we love turning a cheap Raspberry Pi into something that actually makes life easier, and this smart doorbell is one of the quickest projects you can pull off on a weekend.

---

## What you’ll need  

### Hardware list  

- **Raspberry Pi** (any model with a 40‑pin header, Pi 3 or Pi 4 works best)  
- **Breadboard** and a few jumper wires  
- **Momentary push button** (the kind you find on a typical doorbell)  
- **220 Ω resistor** (to protect the button input)  
- **USB microphone** or a simple **piezo buzzer** for audio feedback  
- **Power supply** for the Pi (5 V 2 A minimum)  

### Software list  

- **Raspbian / Raspberry Pi OS** (latest Lite version is fine)  
- **Python 3** (pre‑installed on the OS)  
- **pip** packages: `gpiozero`, `requests`, `pillow` (optional for photos)  

All of these parts can be found on Amazon, eBay, or a local electronics store.  The total cost stays under $30, which is a nice little win for a project that feels like a home‑automation upgrade.

---

## Wiring it up  

1. **Place the button on the breadboard.**  
2. Connect one leg of the button to **GPIO 17** (pin 11 on the header).  
3. Hook the other leg through the **220 Ω resistor** to **ground** (pin 9).  
4. If you’re using a buzzer for a chime, wire the positive lead to **GPIO 27** (pin 13) and the negative to ground.  
5. Plug the USB microphone into one of the Pi’s USB ports.  

That’s it—no fancy soldering, just a few clips.  At PiCode Lab we always double‑check that the Pi is powered off while wiring, just to keep the static shock risk low.

---

## Writing the Python code  

Open a terminal on your Pi (or SSH in) and create a new file called `doorbell.py`.

```bash
nano doorbell.py
```

### Detecting the button  

```python
from gpiozero import Button, Buzzer
import time

button = Button(17, pull_up=False)   # pull_up=False because we use a resistor to GND
buzzer = Buzzer(27)

def ring():
    buzzer.on()
    time.sleep(0.2)
    buzzer.off()
```

The `Button` class handles debouncing for us, so we don’t have to write any extra code to filter out false presses.

### Sending a notification  

You can choose how you want to be alerted.  The simplest way is to fire a **IFTTT webhook** that sends a push notification to your phone.

```python
import requests

IFTTT_KEY = "your_ifttt_key_here"
IFTTT_EVENT = "doorbell_press"

def notify():
    url = f"https://maker.ifttt.com/trigger/{IFTTT_EVENT}/with/key/{IFTTT_KEY}"
    requests.post(url)
```

If you prefer a text message, swap the `notify` function with a Twilio API call.  At PiCode Lab we keep things modular: you can replace the body of `notify()` without touching the rest of the script.

### Putting it together  

```python
def on_press():
    ring()
    notify()
    print("Doorbell rang!")

button.when_pressed = on_press

# Keep the script alive
while True:
    time.sleep(1)
```

Save the file (`Ctrl+O`, `Enter`, `Ctrl+X`).  Run it with:

```bash
python3 doorbell.py
```

If everything is wired correctly, pressing the button should make the buzzer chirp and your phone buzz with a notification.

---

## Testing and tweaking  

1. **Check the button response.**  If you hear a click but the script doesn’t print “Doorbell rang!”, double‑check the GPIO pin numbers.  
2. **Adjust the chime length.**  Change the `time.sleep(0.2)` value in `ring()` to make the sound longer or shorter.  
3. **Add a camera snapshot.**  If you have a Pi Camera attached, import `picamera` and capture an image inside `on_press()`.  Then send that image to IFTTT as an attachment – a handy way to see who’s at the door.  

Because the code is only a few dozen lines, you can experiment without fearing you’ll break anything.  At PiCode Lab we love that the whole project fits on a single script; it’s perfect for learning Python’s interaction with hardware.

---

## Wrap‑up  

You’ve just turned a $5 push button into a smart doorbell that notifies you wherever you are.  The biggest win here isn’t the notification itself—it’s the confidence you gain in wiring GPIO pins, using `gpiozero`, and calling web APIs from your Pi.  Next time you’re at PiCode Lab, try swapping the buzzer for a small speaker and play a custom WAV file, or integrate a facial‑recognition model to greet friends by name.

Remember: the goal isn’t to build a flawless product in a day, but to get comfortable with the loop of “hardware → code → test”.  With that mindset, the next project—maybe a temperature‑aware thermostat or a garden‑monitoring system—will feel just as approachable.

Happy hacking, and let us know how your doorbell works out on the PiCode Lab community forum!