(intimidating) Intelligent Doorbell
by Kent Vanderlinden in Workshop > Home Improvement
170 Views, 2 Favorites, 0 Comments
(intimidating) Intelligent Doorbell
Lately I've been ordering a lot of packages to my home, but no one was available to take it either because of work or simply because I was too busy to answer the door.
Because of this, my package ended up just laying in front of my door or it was sent to a different location.
So I have been working on an intelligent doorbell (prototype) that solves this issue, and a lot more.
The doorbell detects the type of visitor and acts based off the classification. It allows you to set instructions for specific visitors along with specified time and date, these instructions will then autonomously be forwarded when the specified class was detected, taking these worries out of your hands.
Let's get to it!
Supplies
Components
- Raspberry Pi (5, 8GB)
- Power supply (27W)
- LCD Screen
- 2 buttons
- Camera (USB)
- Speaker (USB)
- Housing
Tools
- Screwdriver
- 3D printer (or access to one)
- Soldering iron (optional, but recommended for more secure connections)
- calipers (for accurate measurements)
- Computer
Materials
- PLA or ABS filament for 3D printing (or any other strong material)
- Velcro tape
- Double sided tape
- (jumper) wires
- Screws and nuts (for securing components)
Software
- Fusion360 (or any other 3D modeling software)
- Slicing software (Ultimaker Cura, PrusaSlicer, etc.)
- Python
- piCamera2
- mediapipe
- requests
- gradio
- numpy
- spidev
- supervision
- rpi-lgpio
- smbus2
- ultralytics
- opencv
- piper-tts
- pygame
Downloads
Measure Your Components
Before we start designing our housing, we first need to measure the components so that we can integrate this into our design.
I used (digital) callipers as these can take the most accurate and precise measurements
You absolutely want to make sure to take everything (that is important) into account, there are imperfections in some components and not everything might be aligned as well as you might think.
Note: There are different ways to measure with callipers
There are 4 different ways you can measure something, with each its perks and uses.
Make sure to educate yourself on it.
To map the components' measurements I used Fusion360 to turn it into a 3D model.
Design the Base
Let's get straight to the point, design a casing to strap the components in.
We'll start with the base
I used Autodesk Fusion360 to design my housing and then 3D printed it. But this can be modelled using other software like "Blender" or "Solidworks".
Design the Lid
In order to secure our components we need a lid as well, this (in my case) will be secured to the base using screws. Make sure to take into account the following things when designing the lid.
- Screw holes (make sure to align these with the base)
Print Your Design
Now that you've designed your casing, it's time to 3D print it. Make sure to use a strong material like PLA or ABS, and consider the layer height and infill percentage for durability.
I will use an Ultimaker printer to print the housing
Note: You first need to "slice"
You can't just pass the STL file to the printer, you first need to slice it into layers that the printer can understand. This is done using slicing software like Ultimaker Cura or PrusaSlicer.
This also automatically adds support to the design in case it's needed
Assemble the Components
Once the printing is done, it's time to assemble the components into the housing.
How the components are secured
LCD Screen
Secured using screws
Raspberry Pi
Secured using velcro tape, this allows for easy removal of the Pi in case of maintenance or upgrades.
Buttons
Secured using the nuts that come along with the buttons, these are screwed in from the inside of the housing.
Speaker
Secured using the clamp that comes along with the speaker, this certainly can be done in a more elegant way but it does the job.
Camera
Secured using double sided tape, this is definitely not the most secure way to do it but it does the job for now, I will probably change this in the future.
Connect the Components
Now that everything is secured, it's time to connect the components together. Make sure to connect the buttons to the GPIO pins of the Raspberry Pi, and connect the camera and speaker to the USB ports.
GPIO Mappings:
This can obviously be changed but this is how I connected my components to the Raspberry Pi.
Soldering
If you want to make the connections more secure, you can solder the wires to the pins of the Raspberry Pi. This is not necessary but it can prevent loose connections in the future.
Though I would recommend to solder the wires to the buttons, this is a more secure way to connect them to the GPIO pins of the Raspberry Pi.
Gather & Annotate Data
In order for the doorbell to detect the type of visitor, we need to gather and annotate data. This can be done by taking pictures of different types of visitors (e.g. family, friends, delivery person, etc.) and annotating them with the corresponding class.
I used Roboflow to gather and annotate my data, this is a great tool to use for this purpose.
Train the Model
Once we have gathered and annotated our data, it's time to train our model.
Export your data from Roboflow.
Training will (in my case) be done locally using the Ultralytics YOLOv26 model, but this can also be done in the cloud using services.
Let's Get to the Pi
Now that we have our model trained, it's time to deploy the Raspberry Pi. Make sure to install all the necessary dependencies and libraries on the Raspberry Pi.
We won't get into too much detail on how to prepare your Pi to start the software development as there are a LOT of steps to this, but I will give you a few pointers.
- Prepare the SD card with Raspberry Pi OS
- Plug in ethernet cable (for easier setup)
Remote - SSH
To make the development process easier, you can use Remote - SSH to connect to your Raspberry Pi from your computer. This allows you to write and run code from Visual Studio Code directly on the Raspberry Pi without having to access it via SSH or something like that.
Or you can also fetch my Github repository and completely skip the coding part.
Prepare Code for the Components
To make everything easier, it's best to already make some classes and methods for the components we're going to use, it's better to micromanage all this now rather than later when we have to integrate everything together.
Database
To store all the data we might need for the application like configuration, logs, instructions... we need a database like PostgreSQL, This is what I will be using. Feel free to use another database if you prefer, the choice is yours.
We'll also use tools like adminer to manage our database, this is a web-based tool that allows you to easily manage your database without having to use CLI commands.
Docker
My database is running in a Docker container, this is not necessary but it makes it easier to manage and maintain. You can also install PostgreSQL directly on the Raspberry Pi if you prefer.
FastAPI
In order for other applications (like our Gradio interface) to communicate with the database, we need to create an API using FastAPI. This will allow us to easily fetch and update data in the database from our Gradio interface.
For this to work we need to create endpoints for the different actions we want to perform, like fetching data, updating data, etc. This will be done using FastAPI's routing system.
Gradio Interface
We now need a user interface to interact with our doorbell, this will be done using Gradio.
Gradio is a great tool for creating web-based interfaces, it makes front-end development a lot easier and faster.
Connect Everything Together
Now that we have all the components, the database, the API and the interface ready, it's time to connect everything together. This is where we will integrate the model, the database, the API, the GPIO related-code, and the Gradio interface into one cohesive application that runs on the Raspberry Pi.
I won't get too much into detail because it's a complicated and big process.
Test the Doorbell
Now that everything is connected, it's time to test the doorbell. Make sure to test all the functionalities like detecting visitors, sending instructions, and logging data to the database.
Autostart the Application
To make sure that the doorbell application starts automatically when the Raspberry Pi boots up, we can use systemd to create a service that runs our application. This way, we don't have to manually start the application every time we turn on the Raspberry Pi.
First create a systemd service file
Make sure to change the paths and the user to match your setup
Then enable the service
Finalize the Design
Finally we can secure our lid to the base using screws, and make sure everything is properly secured and in place.
Congratulations! You have successfully created an intelligent doorbell that can detect the type of visitor and act based on the classification. This is just a prototype, but it can be further improved and expanded with more features and functionalities.
Thank you for following along, I hope you learned something new and had fun building this project!