Ultrasonic sensor HC-SR04 is utilized here to recognize the presence of any person at the door. The sensor module involves an ultrasonic transmitter, receiver as well as a control circuit. It includes two circular eyes out of which one is utilized to transmit the ultrasonic wave and the other to receive it.
(Learn more about such IoT Applications)
We can estimate the distance of the object depends on the time taken by the ultrasonic waves to return back to the sensor. With the help of formula:
Distance = (Time x Speed of Sound) / 2
Trigger pin of the ultrasonic sensor is attached to pin no. 12 of Arduino and Echo pin of sensor is attached to pin no 11 of Arduino. Vcc of the sensor is attached to the 5V pin of Arduino and the GND of the sensor is attached to the GND of Arduino. One pin of the buzzer is connected to the GND of Arduino and the other pin is connected to the 8th pin of Arduino.
Working of Project
Whenever anyone comes within the range of Ultrasonic Sensor, the microcontroller recognizes the distance of the object from the sensor and if the object is within the defined range, it sends the High signal to the buzzer and buzzer will start beeping.
We can test the entire circuit by simply putting anything in front of the sensor within a specific range.