Saturday, December 21, 2024

LDR Plus GSM Based Security System

This LDR Plus GSM Based Security System project will teach us how to make a smart device that can notify us whenever any unauthorised person opens the safe box/drawer.

We all use safe boxes or drawers to keep our necessary belongings but sometimes aren’t sure how secure it is. We worry about what if someone breaks the lock and opens our drawer/safe box to take our private documents. And here, we need a system that can alert us whenever anyone opens the safe box/drawer without our permission. 

LDR Plus GSM Based Security System Prototype
Fig 1. LDR Plus GSM Based Security System Prototype

This project will teach us how to make a smart device that can notify us whenever any unauthorised person opens the safe box/drawer. Basically, the device is based on light- dependent sensing. So, when any drawer or box is in a closed state, it is all dark inside and no light is detected. But as soon as the drawer is opened, the light gets detected and the smart device gives an alert about that. 

- Advertisement -

Now, you might think what if anyone tries to open it at night? To find any box or drawer, the introducer will be using at least a small amount of light. As the smart device is very light- sensitive, it can easily detect even a small amount of light.

In this project, we are going to use an LDR that is connected to Arduino analogue pin A1 (for reading the change in resistivity).

- Advertisement -

So let’s start our project by shopping the following components:

Bill Of Materials

Bill of Material for LDR Plus GSM Based Security System
Bill of Material for LDR Plus GSM Based Security System

Coding

Assuming you already have an Arduino IDE installed in your PC, open the library manager and then install the “Adafruit Fona” library in it. 

To begin coding, first, initialise the required library in the code. After that, define the pins for LDR and SIM800l for serial communication. Next, we will create a setup function where we start the software serial communication with SIM800l at a baud rate of 4800 (default baud rate of SIM800l) and then set the A1 pin as INPUT.

Next, we will create a loop function that will run repeatedly. In the loop function, we will check the LDR value and create a code that reads the message on the SIM800l module. If the SIM800l has a new message, then it sets that message to the command string.

The if condition() checks the LDR value. If the value is greater than 2, it means that light has been detected and the box is open. Then it checks the command string to match with a preset command or you can say a unique code that only the user knows. If the command string did not match then it sends an SMS alert and also triggers the buzzer, notifying that some unknown person is trying to open the safe box/drawer. (Refer Fig. 2, 3, 4).

Note: Please change the unique code and the phone number accordingly. (Refer fig. 5)

Fig 2.
Fig 3.
Fig 4.
Fig 5.

Connection

Now upload the code to Arduino and connect the components as shown in the circuit diagram

LDR+GSM Based Security System Connection diagram created in Fritzing
Fig 6. LDR+GSM Based Security System Connection diagram created in Fritzing
Circuit diagram for GSM Based Security System Connection diagram
Fig 7. Circuit diagram for GSM Based Security System Connection diagram

Now, after the connection, let’s test our prototype.

Testing

Insert any working 2G SIM in the SIM800l Module. Now put the device in any box and then power it using a 5-12 V battery or a USB cable. Wait for a few seconds so that the SIM800l module gets registered with the network. When the SIM800l gets registered, its red LED will start to blink slowly. Now close the box. When you open it, you will get a message your phone regarding the opening of the box. The buzzer will also start making a noise. Now send this unique code (known only to the owner of the device) to the sim card number. Here, the unique code is  “unlock124” to open the box. After detecting that the owner has opened the box, it will not send any further SMS alert.  

This article is a part of the Top 10 LDR-based Electronics Projects Listicle. If you want to read more projects based on LDRs can go through this article.

Download Source Code


 

Ashwini Sinha
Ashwini Sinha
A tech journalist at EFY, with hands-on expertise in electronics DIY. He has an extraordinary passion for AI, IoT, and electronics. Holder of two design records and two times winner of US-China Makers Award.

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics