Friday, September 22, 2023
Google search engine
HometelecomARDUINO – MOTION SENSOR

ARDUINO – MOTION SENSOR

1. Introduction

Currently, with the continuous development of science and technology, all daily activities are automated, robots gradually take over many positions in our daily lives. In order to have the correct and efficient operation of automation devices, sensors are one of the key components. Motion sensors are one of them, which can help detect the movement of people or objects, thereby helping mechanical devices have the correct control signals.
In this article, we will show you how to connect and operate the PIR motion sensor with Arduino Uno R3 using visual studio code included with IO IDE platform. Through this tutorial, you will be able to apply motion sensors to your projects, making your products smarter.

2. SENSOR-MODULE/EXPANSION BOARD PINOUT DIAGRAM

2.1. Hardware Introduction

2.1.1. Arduino UNO R3

Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. You can tinker with your Uno without worrying too much about doing something wrong, worst case scenario you can replace the chip for a few dollars and start over again.
“Uno” means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of Arduino, now evolved to newer releases. The Uno board is the first in a series of USB Arduino boards, and the reference model for the Arduino platform; for an extensive list of current, past or outdated boards see the Arduino index of boards.

Features

ATMega328P Processor

Memory

+ AVR CPU at up to 16 MHz
+ 32KB Flash
+ 2KB SRAM
+ 1KB EEPROM

Security

+ Power On Reset (POR)
+ Brown Out Detection (BOD)

+ Power On Reset (POR) + Brown Out Detection (BOD)

Peripherals

+ 2x 8-bit Timer/Counter with a dedicated period register and compare channels
+ 1x 16-bit Timer/Counter with a dedicated period register, input capture and compare channels
+ 1x USART with fractional baud rate generator and start-of-frame detection
+ 1x controller/peripheral Serial Peripheral Interface (SPI)
+ 1x Dual mode controller/peripheral I2C
+ 1x Analog Comparator (AC) with a scalable reference input
+ Watchdog Timer with separate on-chip oscillator
+ Six PWM channels
+ Interrupt and wake-up on pin change

Power

+ 2.7-5.5 volts

2.1.2. Motion sensor

A motion sensor (or motion detector) is the linchpin of your security system because it detects when someone is in your home when they shouldn’t be. A motion sensor uses one or multiple technologies to detect movement in an area.
When a sensor detects motion, it sends a signal to your security system’s control panel, which connects to your monitoring center. This alerts you and the monitoring center to a potential threat in your home.

Types of motion sensors:

Passive infrared (PIR)

A passive infrared sensor detects body heat (infrared energy) by looking for changes in temperatures. This is the most-widely-used motion sensor in home security systems. When you arm your system, this activates the motion sensors to report possible threats.
A passive infrared sensor detects body heat (infrared energy) by looking for changes in temperatures. This is the most-widely-used motion sensor in home security systems. When you arm your system, this activates the motion sensors to report possible threats.

Microwave (MW)

This type of sensor sends out microwave pulses and measures the reflections off of moving objects.1 They cover a larger area than infrared sensors but are more expensive and vulnerable to electrical interference.

Dual technology motion sensors

Some motion sensors can combine multiple detection methods in an attempt to reduce false alarms. For example, it’s not uncommon for a dual technology sensor to combine a passive infrared (PIR) sensor with a microwave sensor.

Each sensor type operates in different areas of the spectrum (ranging from passive to active). Dual technology motion sensors are not as likely as other types to cause a false alarm, because both sensors need to trip in order to sound an alarm. However, this does not mean that they never cause false alarms.
In this tutorial, I will use PIR sensor (picture 6)

Specification:

+ Voltage: 5V – 20V
+ Power Consumption: 65mA
+ TTL output: 3.3V, 0V
+ Delay time: Adjustable (.3->5min)
+ Lock time: 0.2 sec
+ Trigger methods: L – disable repeat trigger, H enable repeat trigger
+ Sensing range: less than 120 degree, within 7 meters
+ Temperature: – 15 ~ +70
+ Dimension: 32*24 mm, distance between screw 28mm, M2, Lens dimension in

diameter: 23mm

2.1.3. Module relay

The relay module is an electrically operated switch that allows you to turn on or off a circuit using voltage and/or current much higher than a microcontroller could handle. There is no connection between the low voltage circuit operated by the microcontroller and the high power circuit. The relay protects each circuit from each other.
The each channel in the module has three connections named NC, COM, and NO. Depending on the input signal trigger mode, the jumper cap can be placed at high level effective mode which ‘closes’ the normally open (NO) switch at high level input and at low level effective mode which operates the same but at low level input.

Specification:

+ On-board EL817 photoelectric coupler with photoelectric isolating antiinterference ability strong
+ On-board 5V, 10A / 250VAC, 10A / 30VDC relays
+ Relay long life can absorb 100000 times in a row
+ Module can be directly and MCU I/O link, with the output signal indicator
+ Module with diode current protection, short response time

2.2. How to connect

Source code:

#include <Arduino.h>
#define PIN_PIR       7
#define PIN_RELAY     2
void setup()
{
Serial.begin(115200);
pinMode(PIN_PIR,INPUT);  // set pin 7 input
pinMode(PIN_RELAY,OUTPUT); // set pin 2 output
digitalWrite(PIN_RELAY,LOW); // turn off relay
}
void loop()
{
if (digitalRead(PIN_PIR) == true)
{
Serial.println(“have motion”);
digitalWrite(PIN_RELAY,HIGH);
delay(5000); // turn on light 5s
digitalWrite(PIN_RELAY,LOW);
}
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments