We have heard of events/parties going out of control due to gate crashing by uninvited guests. Now, as a solution, imagine your door counting the number of invitees and raising an alarm when the number exceeds the guest list. It could have sounded like a magic door some years back, but it is a reality today. We can call it a smart door and the thing that is making it smart is a gate-crashing alarm system that we are going to build today in this DIY project.
This technology can also be used to prevent entry of criminals inside our house by simply installing it in our push & pull door.
The door alarm system prototype that we are going build today can detect entry of up to three to four persons, but it can be upgraded as per requirement.
It will count the number of times the door opens and will automatically raise alarm when it detects the extra person. This is enabled by using a gesture sensor that senses the door’s movement from left-right or right-left. If you find gesture sensor a little bit costly, and want a cheaper alternative, do write us in the comment section. We will make another less expensive solution for you.
To start this project, we need the following electronic components which are easily available in the market:-
Bill of Material for Visitor Counter
Open IDLE and the library manager, after that install the Sparkfun library of APDS9960 in Arduino IDE (Fig 1).
Next initialize the ‘Sparkfun APDS9960’ library and then create variables to store different values. Now, create a setup function where you can create the code for checking the connection in the gesture sensor. Then create a loop function to check the interrupt pin. When any movement happens near the sensor, the loop calls a gesture handle function.
In gesture handle function, we check the gesture from the sensor. When we open our door, this function checks the gesture from left-right or right-left. If it detects the gesture towards the left (i.e. when someone enters through the door), then there will be an increment in ‘count’ variable. We have another ‘if condition’ that checks the count value. When the total number of people entering through the door exceeds four, then it automatically makes loud sound.
You can download the code from link below:
Now connect the components as illustrated below
|GND||APDS9960 GND & BUZZER GND|
|3.3 V||APDS9960 VCC|
|PIN 11||BUZZER VCC|
Testing for Visitor Counter
After you are done connecting all the components, do crosscheck each connection as any wrong connection can fry your costly dev board. After ensuring that all is fine, you can fix the sensor near the door and check the circuit by moving your hand.
For testing, power the Arduino using any 5v power supply, then move your hand near the gesture sensor from left- right or right-left. Each time it detects the left gesture, it will add 1 to the count value. When this number exceeds 4, the sensor will automatically start the alarm buzzer.