0

members

Easy Basics: Project 026g PIR sensor HC - SR 501 or HC - SR 505, Photoresistor, 5V Relay module - night s

of Acoptex.com in UNO

Basics: Project 026g

Project name: PIR sensor HC - SR 501 or HC - SR 505, Photoresistor, 5V Relay module - night security system

Tags: Arduino, Arduino Uno, PIR sensor HC - SR 501, HC - SR 505, Photoresistor, Photocell, 5V Relay module, night security system, night security light

Attachments: sketch

WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION. 

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3.Jumper cables M-M, F-M

4. Resistor 1 pc (10 kOhm) and 1 pc (220 Ohm) for LED optional

5. Photocell (photoresistor) 1 pc

6. Breadboard 1 pc

7. PIR sensor HC - SR 501 or HC - SR 505 1 pc

8. 5V Relay module 1 pc

9.Light bulb 60 W 220 V with connector 1pc

10. LED 1 pc optional

General

We will learn how to make a night security system with a PIR sensor, a photocell and a 5V Relay module and use it with Arduino board. A night security light turns on only when it’s dark and when movement is detected.

Project notes:

  • A lamp turns ON when it’s dark and a movement detected;
  • A lamp stays ON for 10 seconds after a movement detected;
  • When the lamp is ON and detects movement it will start to count 10 seconds again;
  • When there is light, the lamp is OFF even when motion detected.

Understanding the 5V relay

You can read more about it here.

Understanding the PIR sensor

You can read more about it here.

Understanding Photocell (Photoresistor)

You can read more about it here and here.

Signals and connections of photocell

Attach one end of photoresistor to power. On the otherside, attach a 10 KOhm resistor to ground. This resistor is in series with the photoresistor, and together they form a voltage divider. The voltage at the point where they meet is proportionalto the ratio of their resistances, according to Ohm’s Law. 

Signals and connections of the PIR sensor

Most PIR modules have a 3-pin connection at the side or bottom. The pinout may vary between modules. One pin will be ground, another will be signal and the final one will be power. Power is usually 3-5VDC input but may be as high as 12V. Sometimes larger modules don't have direct output and instead just operate a relay in which case there is ground, power and the two switch connections.The output of some relays may be 'open collector' - that means it requires a pullup resistor. If you're not getting a variable output be sure to try attaching a 10K pullup between the signal and power pins. An easy way of prototyping with PIR sensors is to connect it to a breadboard since the connection port is 0.1" spacing. Some PIRs come with header on them already, the one's from adafruit have a straight 3-pin header on them for connecting a cable.

Signals and connections of 5V relay

The SRD-05 VDC-SL-C relay has three high voltage terminals (NC, C, and NO) which connect to the device you want to control. The other side has three low voltage pins (Ground, Vcc, and Signal) which connect to the Arduino.

NC: Normally closed 120-240V terminal

NO: Normally open 120-240V terminal

C: Common terminal

Build the circuit

WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION. 

Make sure that the high voltage connections to the 5V relay module are very well secured. Identify the hot power wire (red wire in the diagram above) in the cord leading to the light bulb and make a cut. Connect the side leading to the light bulb to the NO terminal of the 5V relay, and the side leading to the plug to the C terminal. This way the relay is on the hot side, and current is switched before it reaches the light bulb. It’s dangerous to put the relay on the neutral wire, since if the device fails current can still fault to ground when the relay is off.

The following picture shows the needed connections with the Arduino Uno.

Code

Do not upload a code to your Arduino board while your lamp connected to the mains. You should unplug the lamp from mains before upload a sketch to your Arduino board.

We will use NO (Normally open) configuration, when the relay receives a HIGH signal the 120-240V switch closes and allows current to flow from the C terminal to the NO terminal. A LOW signal deactivates the relay and stops the current. 

Step by Step instruction

  1. Do wiring.
  2. Do not upload a code to your Arduino board while your lamp connected to the mains. You should unplug the lamp from mains before upload a sketch to your Arduino board.
  3. Open Arduino IDE.
  4. Plug your Adruino Uno board into your PC and select the correct board and com port.
  5. Open, verify and upload the sketch to your Adruino Uno board. 
  6. Open up serial monitor and set your baud to 115200 baud.
  7. A night security light turns on only when it’s dark and when movement is detected. During day time the night security light will be off but movement will be detected.
  8. Note that after powering the sensor module it needs about 20 – 60 seconds to “warm-up” in order to function properly. Now when you will put your hand in front of the sensor the relay will activate the lamp. But note that even if you move your hand constantly the lamp will turn off after the adjusted delay time is over because the PIR sensor is in “non-repeatable trigger” mode. If you change the sensor with the jumper to the “repeatable trigger” mode and you constantly move the hand, the lamp will be constantly on as well and it will turn off after the movement is gone and the set delay time is over.
  9. We suggest first to assemble the circuit and test it with LED before using the lamp and mains. See the picture below.

Summary

We have learnt how to make night security system with a PIR sensor, a photocell and a 5V Relay module and use it with Arduino board.

Library:

  • No libraries required for this project

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Acoptex.com
Easy Basics: Project 083d Sipeed Maixduino Kit for RISC-V AI and IoT of Acoptex.com in ESP8266 ESP-32 16-06-2019
Easy Basics: Project 076f ESP32 Development board - How to use GPIO pins of Acoptex.com in ESP8266 ESP-32 03-06-2019
Easy Basics: Project 082a Lithum battery charger TP4056 of Acoptex.com in UNO 01-06-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 20-11-2018
Viewed: 450 times