Home Security System Using Ultrasonic Sensor With GSM
GSM Based Home Security System Using Ultrasonic Sensors
Introduction
In this article, we will make a project based on the security system and we will guide you in building a security alarm system using an Arduino Uno. This project is used in various fields like home security, office security and another system.DIY project generated an alarm system that can detect any movement and send notifications to a particular mobile number via SMS.
Components Needed
S.N | Components | Quantity | Link to Buy |
1 | Arduino Uno | 1 | |
2 | Ultrasonic Sensor | 1 | |
3 | GSM sim800l Module | 1 | |
4 | Buzzer | 1 | |
5 | LM2596 Step Converter | 1 | |
6 | Wire | 1 | |
7 | Zero PCB | 1 | |
8 | 9v power supply | 1 |
Arduino Uno
The Arduino Uno is a big-size microcontroller board based on the ATmega328P IC. It is part of the Arduino family of development boards with the popular Arduino environment. However, the uno is big in size and is a total of 14 digital pins available and a total of 6 analog pins available and also supports UART, SPI and I2C Communication.
ATmega328P microcontroller
- The clock speed of 16 MHz.
- The flash is the memory of 32KB for storing the program code
- The SRAM for 2KB of data storage
- The EEPROM of 1KB for non-volatile storage.
- The digital and analog input/output pins can be used to interface with sensors, actuators, and other electronic components. It totals 14 digital I/O pins & 8 analog input pins.
The supports
- 9v Dc Power Supply.
- UART (Universal Asynchronous Receiver&Transmitter).
- SPI (Serial Peripheral Interface).
- I2C (Inter-Integrated Circuit).
- These all are interfaces with other devices such as sensors, displays, and wireless modules.
Ultrasonic Sensor
- The ultrasonic sensor is a device that uses sound waves of high frequency to measure distances.
- the work of transmitter and a receiver that work together to emit and receive ultrasonic waves.
- Transmitter generated the high-frequency sound waves, typically in the range of 40 kHz to 200 kHz.
- Receiver received the sound waves and travels through the air until they encounter an object. When the sound waves hit the object, they get reflected back towards the sensor. a receiver detects the reflected sound waves and converts them into electrical signals.
- Formula to calculate the Distance = Speed of Sound × Time / 2.
GSM sim800l Module
The SIM800L GSM module is a small device that communicates over the Global System for cellular network Communications. The module connects to a Mobile cellular network and transmits data, make voice calls, and sends text messages.
- The module has a backside SIM card slot available, which can accept a SIM card 2G or 3G SIM card.
- The works in a frequency range of 850MHz to 1900MHz. It also works with AT commands.
- The GSM Module requires a power supply of around 3.7 to 4.2 volts.
Circuit Diagram
- Connect the VCC and GND pins of the ultrasonic sensor to the 5V and GND pins of the Arduino Nano, respectively.
- Connect the Trig and Echo pins of the ultrasonic sensor to any two digital pins of the Arduino Nano (6 and 7).
- Connect the positive terminal of the buzzer to a digital pin of the Arduino Nano (13) and the negative terminal to GND.
- Connect the TX and RX pins of the SIM800L module to the 2 and 3 pins of the Arduino Nano, respectively. Use voltage dividers or level shifters to convert the 5V Arduino logic to the 3.3V required by the SIM800L module.
Source Code
- Program the Arduino Nano using the Arduino IDE or any compatible programming environment.
- Initialize the necessary libraries and define pins for the ultrasonic sensor, buzzer, and GSM module.
- Implement the required functions for ultrasonic distance measurement, alarm triggering, and CALL sending.
- Set up the GSM module to establish communication with the mobile network and enable CALL functionality.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
//Prateek //https://justdoelectronics.com //https://www.youtube.com/c/JustDoElectronics/videos #include <SoftwareSerial.h> const String PHONE = "+918830584864XX"; #define rxPin 2 #define txPin 3 SoftwareSerial sim800(rxPin, txPin); #define trigPin 6 #define echoPin 7 void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(115200); sim800.begin(9600); Serial.println("SIM800L software serial initialize"); sim800.println("AT"); delay(1000); } void loop() { while (sim800.available()) { Serial.println(sim800.readString()); } while (Serial.available()) { sim800.println(Serial.readString()); } long time_duration, distance_in_cm; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); time_duration = pulseIn(echoPin, HIGH); distance_in_cm = time_duration / 29 / 2; Serial.print(distance_in_cm); Serial.println(" cm"); if (distance_in_cm <= 10) { Serial.println("Motion detected!"); Serial.println("calling...."); sim800.println("ATD" + PHONE + ";"); delay(20000); //20 sec delay } delay(500); } |
Project Demo
- The ultrasonic sensor detects movement and measures the distance to the object.
- If the distance falls below a specified threshold, indicating unauthorized movement, the system triggers the buzzer to produce an audible alarm.
- Simultaneously, the GSM SIM800L module sends a CALL notification to the user’s mobile device, providing details of the security breach.
Video
Conclusion
The Security Alarm System project demonstrates the successful integration of an ultrasonic sensor, GSM SIM800L module, buzzer, and Arduino Nano to develop a reliable security alarm system. This project offers an affordable and customizable solution for various security applications. By combining hardware components and software programming, the system detects unauthorized movement, triggers an audible alarm, and sends SMS notifications to the user, ensuring enhanced security and peace of mind.
Arduino Based Projects