Automatic home security system project | PIR sensor with Arduino [Step by step instructions]
Automatic home security system project
Hello guys, welcome back to another tutorial from SriTu Hobby. In this tutorial, we will make an automatic home security system project using Arduino. Also, the PIR sensor is mainly used for this project. We can use this project for places like houses, shops, and gates. Also, we can do this project simply at a low cost. This tutorial covers step by step how to do it.
Process of this project
When there is any movement at the point where this security lamp is connected, it is detected by the PIR(Motion) sensor. Then a digital signal is generated through it. Afterward, it is obtained from the Arduino board and turns the relay module ON and OFF. That is, when a movement occurs, the bulb turns ON and turns OFF in a short time. We can control this bulb’s active time and sensing range using the potentiometers in the PIR sensor. Also, we can even use a buzzer for this bulb.
OK, let’s do this project step by step. For that, the required components are as follows.
Secondly, cut a 5*5-inch cardboard piece and 5*2-inch piece cardboard piece. Afterward, adjust the 5 * 2-inch piece of cardboard to fit the Arduino UNO board. Now. glue them as follows.
Step 3
Thirdly, attach the Arduino board and relay module to the base cardboard piece.
Step 4
Next, connect the relay module and the PIR sensor to the Arduino board. For that, use the circuit diagram below.
Step 5
Afterward, cut a 5 * 2-inch piece of cardboard. Then, glue it to the bottom piece.
Step 6
Next, connect the wires to power the relay module and pull them out of the piece of cardboard.
Step 7
Then, cut two 5 * 2-inch pieces of cardboard and glue them to the bottom piece of cardboard.
Step 8
Next, cut a 5 * 5-inch piece of cardboard and attach the PIR sensor to it.
Step 9
Then, pull out the wire that connects the bulb holder through it and glue that piece of cardboard to the main piece of cardboard.
Step 10
Next, connect the bulb holder and AV voltage connector.
Step 11
OK, now connect this project to the computer. For that, use the SUB cable.
Step 12
So, now we will create the appropriate code for this project. It is as follows.
Read the code below and use it for any of your creation
*/
void setup() {
pinMode(2, OUTPUT);//Relay pin
pinMode(3, INPUT);//sensor pin
}
void loop() {
digitalWrite(2, HIGH);//relay off
bool value = digitalRead(3);//read sensor value
if (value == 1) {//check condition
digitalWrite(2, LOW);//relay on
}
}
Code explanation
Firstly, PIR sensor and relay-connected pins are set as input and output pins in the void setup.
void setup() {
pinMode(2, OUTPUT);//Relay pin
pinMode(3, INPUT);//sensor pin
}
Lastly, in the void loop, the sensor values are read and put into the Boolean variable. Then, check these values using the IF condition and if the value is 1, the relay module will be activated. Otherwise, the relay module is turns off.
void loop() {
digitalWrite(2, HIGH);//relay off
bool value = digitalRead(3);//read sensor value
if (value == 1) {//check condition
digitalWrite(2, LOW);//relay on
}
}
Step 13
OK, now select board and port, Afterward, upload this code.
Lastly, connect 230 AC voltage and 5v DC power supply to our project. (You must remember to be careful using AC voltage)
Okay, enjoy this tutorial. I always try to give you a better experience through this blog. But I’m sorry about my knowledge of English. I will try to correct this mistake as soon as possible. The full video guide is below. We will meet in the next tutorial.