members
Basics: Project 026f PIR sensor HC - SR 501 or HC - SR 505, DC 5V servo motor - motion radar-detecti
of Acoptex.com in UNO
Basics: Project 026f
Project name: PIR sensor HC - SR 501 or HC - SR 505, DC 5V servo motor - motion radar-detection system
Attachments: sketch1, sketch 2, library
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. Breadboard
5. PIR sensor HC - SR 501 or HC - SR 505 1 pc
6. DC 5V MG91 or SG90 Micro Servo Motor 1 pc
or
General
We will learn about PIR sensor and how to connect PIR sensor, DC 5V MG91 or SG90 Micro Servo Motor to Arduino board to make motion radar-detection system.
Understanding the servo motors
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.
Build the circuit
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 servo circuit that monitor 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.
Step by Step instruction
- Open Arduino IDE.
- Plug your Adruino Uno board into your PC and select the correct board and com port
- Open up serial monitor and set your baud to 9600 baud
- Verify and upload the the sketch to your Adruino Uno board
- 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.
- PIR sensor controlled relay circuit will turn on a light bulb when the motion detected.
- DC 5V servo motor will be turn to 90 degrees when motion detected and turn to 0 degrees when motion stopped.
- 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










Viewed: 4388 times