Automatic home security system project | PIR sensor with Arduino [Step by step instructions]
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.
- Arduino UNO board x 1 — Our Store / Amazon
- PIR sensor x 1 — Our Store / Amazon
- 1-channel relay module x 1 — Our Store / Amazon
- AC bulb holder x 1– Amazon
- AC bulb x 1 — Amazon
- Jumper wires — Our Store / Amazon
- Cardboard — Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Step 2
Secondly, cut a 5*5-inch cardboard piece and a 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 AC voltage connector.
Step 11
OK, now connect the Arduino board to the computer.
Step 12
Now let’s create the program for this project. It is as follows.
- The complete program of this project – Download
/*PIR sensor table lamp.
Serial monitor readings.
created by SriTu Tech team.
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, the PIR sensor and relay pins are set as input and output pins in the void setup.
void setup() {
pinMode(2, OUTPUT);//Relay pin
pinMode(3, INPUT);//sensor pin
}
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 turned 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.
Finally, connect 230 AC voltage and 5v DC power supply to our project. (You should use AC voltage with care)
Okay, enjoy this project. I always try to give you a better experience through this blog. The full video guide is below. So, we hope to see you in the next project. Have a good day.
Automatic home security system project | PIR sensor with Arduino [Step by step instructions]