PIR Motion Sensor

Not rated 31,308

Circuit Image

The objective of this project is to utilize an inexpensive PIR sensor to detect human movement. A PIC18F25K20 microcontroller is employed to monitor changes in the sensor's state and emit sound through a speaker or piezo buzzer. The microcontroller also checks the battery voltage at startup. The algorithm is straightforward, using an interrupt-on-change mechanism to detect alterations in the PIR sensor's output. PIR sensors are designed to sense motion, primarily for detecting whether a human has entered or exited the sensor's range. They are compact, affordable, low-power, easy to implement, and have a long operational life, making them common in various household and commercial devices.

The core of a PIR sensor consists of a pyroelectric sensor capable of detecting infrared radiation levels. All objects emit a certain level of radiation, and the intensity increases with temperature. The sensor is divided into two halves to detect motion rather than average infrared levels; this configuration allows for cancellation of signals between the halves. Any imbalance in infrared radiation detected by the two halves results in a high or low output signal.

In this project, a 9V battery powers the circuit, controlled by a switch. An L317T voltage regulator provides a stable output of 3.3V, achieved by using two resistors (R1 and R2). R2 is set to 240 ohms, while R1 is calculated using the appropriate equations. An RC delay is implemented on the VPP pin to prevent voltage drops during circuit power cycling, which could lead to an undefined state for the microcontroller upon startup. An 8-ohm speaker is used, although a piezo buzzer could also be employed. A BC338 transistor (Q1) amplifies the sound output, providing an HFE of approximately 35 to ensure audibility across different spaces.

The PIR sensor operates at 3.3V, supplied by the LM317T output, and can accept input voltages ranging from 8V to 24V. Since the circuit uses a 9V battery, it is essential to ensure that the battery voltage does not fall below 8V, which would render the PIR sensor inoperative. The output from the PIR sensor is connected to PORTB.0 of the microcontroller. A pull-down resistor ensures that PORTB.0 remains in a low state when no motion is detected. The sensor has a detection range of 2 to 3 meters and requires 10 to 12 seconds to reset before it can trigger another interrupt.

At startup, both LEDs are illuminated to indicate the system status. The microcontroller tests the battery voltage; if the battery is functional, LED1 (green) blinks three times. If the battery is low, LED2 (blue) blinks three times. Subsequently, LED1 remains illuminated. If PORTB.0 does not change state, the system remains idle until motion is detected. Upon detecting movement, an interrupt is generated, turning off LED1 and activating LED2. A sound is emitted for 5 seconds before LED2 turns off, and the system returns to its main routine.The objective of this project is to use inexpensive PIR sensor to detect if a human has moved. To build this project I use a PIC18F25K20 microcontroller to detect if the sensor had change state and it will emit a sound from the speaker or piezo, the MCU also detect the voltage of the battery in the startup, the algorithm it s very simple it use a n interrupt on change to detect the change on the PIR sensor. PIR sensors allows you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don`t wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses. PIRs are basically made of a pyroelectric sensor, 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. I use a 9V battery and it s connect to a switch and as a voltage regulator I use an L317T and it will have an output of 3, 3V to make that possible I use two resistors R1 and R2 to set the output, i use this equations to calculate R1 and I set R2 to 240 ohms: I had to add a RC delay on VPP pin because when I switch on/off the circuit there was a voltage drop because the PIR Sensor and that would generate an unknown state when the MCU was restarted to solve that I add a RC delay, you can use this equations to calculate the delay I use an 8 ohm speaker but you can use a piezo, i use a transistor BC338 (Q1) because the sound wasn t too loud and should be able to ear that from a different division, with that transistor i get a HFE = 35. You can calculate This PIR Sensor works with only 3. 3V like the MCU so it s connect to the output of LM317T it can be connect to a voltage of 8V to 24V, because I use a 9V battery and if the battery gets lower than 8V the PIR sensor won`t work that is why I connect the output of LM317T.

The Vout of the sensor it is connected to PORTB. 0 and when it occurs a change it will cause an interrupt I use a pull down resistor to make sure the PORTB. 0 it is in a low state. The sensor takes 10 to 12 seconds to cause another interrupt and the range is between 2m and 3m. There are the graphs of this sensor and the delays. At startup both LEDs are on and then it will test the battery if is good Led1(Green) will switch on/off three times, if battery it is low Led2(Blue) will switch on/off three times, next it will put the Led1(Green) on, if PORTB.

0 doesn t change state the circuit will remain the same until a change happen and when a change happen it means the sensor detects some movement and a interrupt will occur and Led1 will be turn off and Led2 will be on and a sound will be generate during 5 seconds and then Led2 will switch off and return to the main routine. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713