Imagine a world where your doorbell is not just a mundane button but an intelligent device that notifies you, streams live video, and even emails you a snapshot of your visitor. Intriguing, right? Thanks to IoT (Internet of Things), Arduino, and platforms like Blynk, you can create an IoT smart doorbell system that transforms how you interact with your front door.
In this comprehensive guide, we’ll explore how to build an IoT Smart Doorbell with an ESP32-CAM, an ESP8266-12E module for internet connectivity, a pushbutton, a PIR motion sensor, and the Blynk IoT platform for seamless interaction.
Conventional doorbells are outdated in today’s connected world. A smart doorbell offers:
If you’re a tech enthusiast, this project is an exciting way to combine creativity and functionality.
Read Also: How to Know the Best Cryptocurrency Exchanges for your Investment
To build this project, you’ll need:
We added a buzzer to let the visitor know when he/she is pressing the pushbutton alert for the smart doorbell. Also the battery displayed here can be made to be rechargeable. We added a servo motor to change the direction of the camera. The PIR motion sensor can also be used to put the camera in video streaming mode.
Reas Also: Injury Prevention: Common Workout Mistakes and How to Avoid Them
The schematic diagram shows the ESP8266 was connected using software serial method to send the data to the Blynk IoT platform.
Download and install the following libraries in the Arduino IDE:
#include <WiFi.h>
#include <ESP32_MailClient.h>
#include <BlynkSimpleEsp32.h>
// Replace with your network credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
// Email configuration
#define SMTP_HOST "smtp.gmail.com"
#define SMTP_PORT 465
#define AUTHOR_EMAIL "YOUR_EMAIL@gmail.com"
#define AUTHOR_PASSWORD "YOUR_EMAIL_PASSWORD"
#define RECIPIENT_EMAIL "RECIPIENT_EMAIL@gmail.com"
// PIR and pushbutton pins
#define PIR_PIN 13
#define BUTTON_PIN 12
// Camera initialization
#include "esp_camera.h"
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
// Blynk credentials
char auth[] = "YOUR_BLYNK_AUTH_TOKEN";
// SMTP client
SMTPData smtp;
// Function to send email
void sendEmailWithImage() {
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
return;
}
smtp.setLogin(SMTP_HOST, SMTP_PORT, AUTHOR_EMAIL, AUTHOR_PASSWORD);
smtp.setSender("Smart Doorbell", AUTHOR_EMAIL);
smtp.setPriority("High");
smtp.setSubject("Visitor at Your Door!");
smtp.setMessage("Motion detected or button pressed. Attached is the image of the visitor.", false);
smtp.addAttachment("visitor.jpg", fb->buf, fb->len);
smtp.addRecipient(RECIPIENT_EMAIL);
if (!MailClient.sendMail(smtp)) {
Serial.println("Error sending Email, " + MailClient.smtpErrorReason());
} else {
Serial.println("Email sent successfully!");
}
smtp.empty();
esp_camera_fb_return(fb);
}
void setup() {
// Serial monitor
Serial.begin(115200);
// Initialize WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected!");
// Initialize Blynk
Blynk.begin(auth, ssid, password);
// Initialize Camera
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
if (psramFound()) {
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 10;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
}
// Camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
// Pin modes
pinMode(PIR_PIN, INPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
Blynk.run();
// Check for PIR motion detection
if (digitalRead(PIR_PIN) == HIGH) {
Serial.println("Motion detected!");
sendEmailWithImage();
delay(10000); // Debounce delay to prevent multiple triggers
}
// Check for button press
if (digitalRead(BUTTON_PIN) == LOW) {
Serial.println("Button pressed!");
sendEmailWithImage();
delay(10000); // Debounce delay
}
}
The code for this project is divided into multiple sections:
The HCSR505 is a compact, low-power motion sensor that works perfectly for detecting human movement.
To minimize false triggers from pets:
Read Also: How to Prepare Recipes for Regulating Blood Sugar
Blynk is a user-friendly IoT platform that simplifies the process of connecting devices to the cloud.
Add a microphone and speaker to enable communication with visitors.
Use IR LEDs with the ESP32-CAM for clear night-time images.
Store captured images and videos on a cloud service like Google Drive for future reference.
Integrate AI to distinguish between humans, pets, and inanimate objects.
Building an IoT Smart Doorbell with Arduino, ESP32-CAM, and Blynk combines creativity, functionality, and security. This project not only upgrades your home’s entry system but also introduces you to exciting IoT concepts. Whether you’re a tech enthusiast or someone looking to enhance their home security, this project is a perfect blend of innovation and practicality.
So, are you ready to build your smart doorbell and take your DIY skills to the next level?
Yes, you can use advanced motion sensors like the Omron D6T for more precise detection.
The HCSR505 has a range of about 3-7 meters and a detection angle of 100 degrees.
Use a stable internet connection and configure your email server settings properly in the code.
Yes, you can use alternatives like MQTT or Firebase for notifications and data handling.
Yes, you can store images on an SD card connected to the ESP32-CAM for local storage.
Introduction Effective Time Management Strategies in today’s fast-paced world, managing time efficiently is more crucial…
Introduction Have you ever caught yourself in the relentless cycle of self-criticism? Maybe you’re constantly…
Introduction Ever feel like your mornings are a chaotic rush, setting the tone for an…
Introduction Have you ever felt the warmth of belonging to a community? It’s a feeling…
Introduction Have you ever felt unheard in a conversation, like your words were floating in…
Introduction Imagine walking through a serene forest, the sunlight filtering through the trees, the soft…
This website uses cookies.