Smart Doorbell

The Buzzer On/Off application is a Python-based project that incorporates an SMD Motor Driver, an add-on Buzzer Module, and an HC-SR04 Ultrasonic Sensor Module to create an interactive system that responds to the proximity of objects. This project is designed to showcase the integration of hardware components and Python programming for a practical application.

Project Key Components:

  1. SMD Motor Driver:

    • The SMD Motor Driver serves as the communication interface between the Python script and the connected hardware components. It interprets commands from the script and translates them into actions that control the Buzzer Module based on Ultrasonic Sensor readings.

  2. Buzzer Module Add-on:

    • An additional Buzzer Module is connected to the SMD Motor Driver. This module functions as the output device, producing sound when activated by the Python script.

  3. HC-SR04 Ultrasonic Sensor Module:

    • The HC-SR04 Ultrasonic Sensor Module is integrated into the project to measure the distance between the sensor and nearby objects. The sensor provides feedback to the Python script, enabling it to determine whether to turn the Buzzer Module on or off.

  4. Python Script:

    • The Python script is the central component of the application. It establishes communication with the SMD Motor Driver, reads data from the HC-SR04 Ultrasonic Sensor Module, and sends commands to control the Buzzer Module based on the proximity of objects.

Project Key Features:

  1. Proximity-Based Activation:

    • The application leverages the HC-SR04 Ultrasonic Sensor Module to continuously monitor the distance to nearby objects. When an object is detected within a specified range, the Python script commands the Buzzer Module to turn on and produce sound. Otherwise, the Buzzer remains off.

  2. Adjustable Sensitivity:

    • The Python script may include parameters to adjust the sensitivity of the proximity detection, allowing users to customize the threshold for activating the Buzzer Module based on their specific requirements.

  3. Real-time Monitoring:

    • The Python script may provide real-time monitoring of the Ultrasonic Sensor readings, giving users insights into how the system responds to the presence or absence of nearby objects.

Project Wiring Diagram:

Getting Started:

  1. Hardware Setup:

    • Connect the SMD Motor Driver to both the Buzzer Module and the HC-SR04 Ultrasonic Sensor Module following the provided documentation.

    • Ensure secure connections and provide appropriate power to the hardware components.

  2. Run the Python Script:

    • Execute the Python script on your computer. This will establish communication with the SMD Motor Driver, continuously monitor the distance to nearby objects through the Ultrasonic Sensor, and control the Buzzer Module based on the sensor readings.

  3. Observe Buzzer Activation:

    • Introduce objects within the specified range of the Ultrasonic Sensor and observe how the Buzzer Module is activated in response to the detected proximity.

Project Codes:

from import *

SerialPort = "COM3"     # Serial port of the USB gateway module
baudrate = 115200       # Baud rate of communication
ID = 0                  # ID of the SMD board
buzzer_module_id = 1       # ID of the buzzer module
distance_module_id = 1    # ID of the ultrasonic distance module

master = Master(SerialPort, baudrate)       # Defines the USB gateway module
master.attach(Red(ID))                      # Gives acces to the SMD of specified ID

while True:
    distance = master.get_distance(ID, distance_module_id)      # Variable to store the ambient light data
    print(distance)                                             # Printing the value to observe 

    if distance < 15:
        master.set_buzzer(ID, buzzer_module_id, 600)            # Number is correspond to the frequency of the buzzer
        master.set_buzzer(ID, buzzer_module_id, 0)              # Sets the buzzer frequency to 0, meaning turning the buzzer off

Last updated