This guide will help you create a Contactless IoT Doorbell system that detects visitors without physical contact. The system uses sensors to detect the presence of a person and sends a notification to your mobile device or home automation system.

Components Required

  • Microcontroller (e.g., ESP32, Arduino with Wi-Fi shield)
  • Ultrasonic distance sensor (e.g., HC-SR04)
  • PIR motion sensor (e.g., HC-SR501)
  • Buzzer or speaker (for sound notifications)
  • Wi-Fi module (if not using ESP32)
  • Power supply (for microcontroller and sensors)
  • Enclosure (to protect the electronics)
  • Mobile app or cloud service account (for notifications)

Setting Up the Hardware

Follow these steps to set up the hardware:

  1. Install the Sensors

    Mount the ultrasonic distance sensor and PIR motion sensor at the entrance. Ensure that the sensors are positioned to detect approaching visitors effectively.

  2. Connect the Sensors to the Microcontroller

    Wire the sensors to the microcontroller. Connect the ultrasonic sensor's trigger and echo pins, as well as the PIR sensor's output pin, to the corresponding input pins on the microcontroller.

  3. Install the Buzzer or Speaker

    Connect the buzzer or speaker to the microcontroller for sound notifications. Ensure that the buzzer is loud enough to be heard from a distance.

  4. Power the System

    Provide a stable power supply for the microcontroller and sensors. Use a battery pack or power adapter suitable for your setup.

Programming the Microcontroller

Write code for the microcontroller to read sensor data and send notifications when a visitor is detected. Here’s a basic outline of the code:


                #include <WiFi.h>
                #include <ESP32HTTPClient.h>

                #define TRIGGER_PIN 5
                #define ECHO_PIN 18
                #define PIR_PIN 4
                #define BUZZER_PIN 2

                const char* ssid = "YOUR_SSID";
                const char* password = "YOUR_PASSWORD";
                const char* serverName = "https://your-cloud-service.com/notify";

                void setup() {
                Serial.begin(115200);
                pinMode(TRIGGER_PIN, OUTPUT);
                pinMode(ECHO_PIN, INPUT);
                pinMode(PIR_PIN, INPUT);
                pinMode(BUZZER_PIN, OUTPUT);
                WiFi.begin(ssid, password);

                while (WiFi.status() != WL_CONNECTED) {
                    delay(500);
                    Serial.print(".");
                }
                Serial.println("Connected to WiFi");
                }

                void loop() {
                if (digitalRead(PIR_PIN) == HIGH) {
                    long duration;
                    float distance;
                    
                    digitalWrite(TRIGGER_PIN, LOW);
                    delayMicroseconds(2);
                    digitalWrite(TRIGGER_PIN, HIGH);
                    delayMicroseconds(10);
                    digitalWrite(TRIGGER_PIN, LOW);
                    
                    duration = pulseIn(ECHO_PIN, HIGH);
                    distance = (duration / 2) * 0.0344;
                    
                    if (distance < 50) { // Adjust distance threshold as needed
                    digitalWrite(BUZZER_PIN, HIGH);
                    
                    HTTPClient http;
                    http.begin(serverName);
                    http.addHeader("Content-Type", "application/json");
                    int httpResponseCode = http.POST("{\"message\":\"Visitor detected\"}");
                    
                    if (httpResponseCode > 0) {
                        String response = http.getString();
                        Serial.println(response);
                    } else {
                        Serial.println("Error sending POST request");
                    }
                    http.end();
                    
                    delay(5000); // Wait 5 seconds before checking again
                    digitalWrite(BUZZER_PIN, LOW);
                    }
                }
                delay(1000); // Check every second
                }
            

This code initializes the sensors, reads data, and sends a notification to a cloud service when a visitor is detected. Adjust the code to fit your specific sensors and notification setup.

Setting Up Notifications

Configure your cloud service or mobile app to receive and display notifications. Ensure that the service can handle the incoming data and alert you when the doorbell is triggered.

Testing and Calibration

Before finalizing the installation:

  1. Test the Sensors

    Ensure that the ultrasonic and PIR sensors are functioning correctly and detecting visitors as intended. Adjust the placement or threshold values if necessary.

  2. Verify Notifications

    Check that notifications are being sent to your mobile app or cloud service correctly. Make sure the notification system is reliable and timely.

  3. Calibrate the System

    Calibrate the distance sensor if needed to ensure accurate detection. Test the system in various scenarios to confirm its performance.

Conclusion

The Contactless IoT Doorbell offers a modern solution for detecting visitors without physical contact. By integrating sensors and notification systems, this project enhances convenience and safety at your home entrance.