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.
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.
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).
So let’s start our project by shopping the following components:
Bill Of Materials
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.)
Now upload the code to Arduino and connect the components as shown in the circuit diagram
Now, after the connection, let’s test our prototype.
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.