0

members

Easy Basics: Project 026d PIR sensor, LEDs, active piezo buzzer, 5V Relay module, servo motor

of Acoptex.com in UNO

Basics: Project 026d

Project name: PIR sensor HC - SR 501 or HC - SR 505, LEDs, active piezo buzzer, 5V Relay module, DC 5V servo motor - motion detection system

Attachments: sketch1, sketch 2, library

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

4. LED 2 pcs (colors - red,green)

5. Resistor 2 pcs (220 Ohm each)

6. Breadboard

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

8. Active  piezo buzzer 1 pc

9. 5V Relay module 1 pc

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

11. DC 5V MG91 or SG90 Micro Servo Motor 1 pc

 or

General

We will learn about PIR sensor and how to connect PIR sensor, LEDs, 5V Relay module, DC 5V MG91 or SG90 Micro Servo Motor and active piezo buzzer to Arduino board to make an advanced motion detection system.

Understanding the servo motors

You can read more about it here.

Understanding the 5V relay

You can read more about it here.

Understanding the piezo buzzer

You can read more about it here.

Understanding the PIR sensor

They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors.

The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.

That’s where the name of the sensor comes from, a Passive Infra-Red sensor. And the term “passive” means that sensor is not using any energy for detecting purposes, it just works by detecting the energy given off by the other objects.

PIRs are basically made of a pyroelectric sensor (which you can see above as the round metal can with a rectangular crystal in the center), which can detect levels of infrared radiation. Everything emits some low level radiation, and the hotter something is, the more radiation is emitted. The sensor in a motion detector is actually split in two halves. The reason for that is that we are looking to detect motion (change) not average IR levels. The two halves are wired up so that they cancel each other out. If one half sees more or less IR radiation than the other, the output will swing high or low.

The module consists a specially designed cover named Fresnel lens, which focuses the infrared signals onto the pyroelectric sensor.

The module has three more pins with a jumper between two of them. These pins are for selecting the trigger modes. The first one is called “non-repeatable trigger” and works like this: when the sensor output is high and the delay time is over, the output will automatically change from high to low level. The other mode called “repeatable trigger” will keep the output high all the time until the detected object is present in sensor’s range.

The module has three more pins with a jumper between two of them. These pins are for selecting the trigger modes. The first one is called “non-repeatable trigger” and works like this: when the sensor output is high and the delay time is over, the output will automatically change from high to low level. The other mode called “repeatable trigger” will keep the output high all the time until the detected object is present in sensor’s range.

You can find a typical PIR sensor datasheet here.

Signals and connections of the servo motors


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 LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of piezo buzzer

Piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND. If you use resistor for piezo buzzer connect it between piezo pin marked (+) sign and Arduino Uno digital pin.

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. 

 Connecting PIR sensors to a microcontroller is really simple. The PIR acts as a digital output so all you need to do is listen for the pin to flip high (detected) or low (not detected).

Its likely that you'll want retriggering, so be sure to put the jumper in the H position!

Power the PIR sensor VCC with +5V and connect GND to ground. Then connect the output to a digital pin. In this project we'll use pin 8.

Let us build a PIR sensor controlled relay circuit that will turn on a light bulb when the motion detected. It can be a powerful light or other equipment connected to 5V relay.The relay has two different types of electrical contacts inside – normally open (NO) and normally closed (NC). The one you use will depend on whether you want the 5V signal to turn the switch on or turn the switch off. The 120-240V supply current enters the relay at the common (C) terminal in both configurations. To use the normally open contacts, use the NO terminal. To use the normally closed contacts, use the NC terminal.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. So if you want the HIGH signal to turn ON the relay, use the normally open terminal.

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.

Step by Step instruction

  1. Open Arduino IDE.
  2. Plug your Adruino Uno board into your PC and select the correct board and com port
  3. Open up serial monitor and set your baud to 9600 baud
  4. Verify and upload the the sketch to your Adruino Uno board
  5. If the motion detected PIR sensor will switch on the red LED and active piezo buzzer and sends the message to Serial monitor, green LED will be off. Green LED will be on, red LED and active piezo buzzer will be off if nothing detected.
  6. PIR sensor controlled relay circuit will turn on a light bulb when the motion detected. 
  7. DC 5V servo motor will be turn to 90 degrees when motion detected and turn to 0 degrees when motion stopped.
  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.

Summary

We have learnt about PIR sensor and how to connect PIR sensor, LEDs, 5V Relay module, DC 5V servo motor and active piezo buzzer to Arduino board to make an advanced motion detection system. 

Library:

  • We will use the Servo library for this project. Servo library included in Adruino IDE program which installed in your PC. It should be here: C:\Program Files (x86)\Arduino\libraries. If you do not have it - see attachement on the begining of this project. Download, unzip and add to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Acoptex.com

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 09-09-2017
Viewed: 723 times