Motion Trigger Circuit With and Without Microcontroller
Introduction: Motion Trigger Circuit With and Without Microcontroller
Greetings
Here's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller to drive XYZ Load when any motion is detected.
This Tutorial contains three different types of setups that we can use to prepare a Motion Detection Based Project like an automatic Hallway Light or Motion Detection Security System Etc.
Let's get started.
Supplies
Following are the materials used in this built-
* PIR HC-SR505 Module
* Attiny13A
* TTGO T Display Board
* LEDs
* Jumper Wires
* BC547
* Breadboard
* USB Micro Port Breakout board
Step 1: HC-SR505
HC-SR505 is a PIR Sensor that picks up infrared radiation emitted by the body and then outputs a signal based on the motion of a body.
You see, as we move, our body emits more and more infrared radiation that is picked up by this sensor.
Following are its electrical parameters and features-
* Operating Voltage Range: DC4.5-20V
* Static current:<60uA
* Output level: High 3.3V / Low 0V
* Trigger: repeatable trigger
* Delay time: Default 8S + -30% (can be customized range of a few tenths - tens of minutes)
* PCB Dimensions: 10 * 23mm
* Induction angle:<100 degree cone angle
* Induction distance: 3 meters
* Working temperature: -20 - +80 degrees
* Sensor Lens Dimensions: Diameter: 10mm
Step 2: PCBWAY GIFTSHOP
As for sourcing the HC-SR505, I got it from PCBWAY's Giftshop.
﻿ Aside from PCB Services, PCBWAY also has a dedicated components store.
PCBWAY GIFTSHOP is an online marketplace from where we can source all the major electronics stuff, like Arduino boards, Raspberry Pi boards, Modules, sensors, etc.
PCBWAY have this system that lets us purchase anything from their gift shop through beans, Beans are like a redeemable currency or coupons that we get by placing an order on PCBWAY or by sharing your projects in the community to get beans.
Check PCBWAY out for getting great PCB service from here- https://www.pcbway.com/
Step 3: First Setup- Basic One
To Prepare the first Setup, we provide VCC and GND of this module with 5V.
We add an LED's VCC Pin on the signal Pin of this module and connect the GND of the LED with the GND of the Module.
This will be the first and most basic Setup we can prepare with this module.
Just by standing near this sensor, It turns ON the LED, LED will stay ON for 8 seconds and then turn OFF, if we are near the 3M Radius of this module, the LED will turn ON again.
Step 4: With Microcontroller TTGO T Display
Here's the second setup that uses a TTGO T Display board to Turn ON and OFF an LED and also display a message when motion is detected on its onboard RGB Display.
Step 5: Preparing TTGO Board for Arduino IDE
We first have to install board files for ESP32 by putting this link in the preferences of the Arduino IDE Settings and then installing the boards through the board manager.
https://dl.espressif.com/dl/package_esp32_index.json
Step 6: Installing TFT_eSPI Library and Making Changes in User Setup
We then move on to the next step which is to install the TFT_eSPI Library that enables us to use the display onboard.
* Next, we go to C:\Users\ACER\Documents\Arduino\libraries\TFT_eSPI and make changes in the User Setup.h by replacing it with User setup for TTGO T Display.
* The default one is set for ILI9430 Display and we change it for TTGO T Display by adding // in front of ILI9430 User setup and removing // in front of TTGO T Display.
Step 7: Connections - Wiring
next, we connect everything by following the attached wiring diagram image.
* VCC of PIR to 5V of TTGO
* GND to GND
* Signal Pin of PIR to D22
* LED's VCC to D21
* LED GND to GND
Step 8: Sketch for TTGO
Here's the code we use.
#define sensor 22
#define LED 21
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI. 982