edit

Grove - PIR Motion Sensor

This sensor allows you to sense motion, usually human movement in its range. Simply connect it to Grove - Base shield and program it, when anyone moves in its detecting range, the sensor will output HIGH on its SIG pin.

Features

  • Grove compatible interface
  • Adjustable detecting distance
  • Adjustable holding time

Tip

More details about Grove modules please refer to Grove System

Specification

Parameter Value/Range
Operating Voltage 3V–5V
Operating Current(VCC = 3V) 100uA
Operating Current(VCC = 5V) 150uA
Measuring Range 0.1 - 6m
Default detecting distance 3m
Holding Time 1 - 25s
Working Wave Length 7 - 14um
Detecting Angle 120 degrees

Platforms Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Getting Started

Note

If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduino before the start.

Play With Arduino

Hardware

  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Grove - PIR Motion Sensor Base Shield
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Connect Grove - PIR Motion Sensor to port D2 of Grove-Base Shield.

  • Step 3. Plug Grove - Base Shield into Seeeduino.

  • Step 4. Connect Seeeduino to PC via a USB cable.

Note

If we don't have Grove Base Shield, We also can directly connect Grove_Ultrasonic_Ranger to Seeeduino as below.

Seeeduino Grove - PIR Motion Sensor
5V Red
GND Black
Not Conencted White
D2 Yellow

Software

  • Copy the code below into Arduino IDE and upload. If you do not know how to upload the code, please check how to upload code.
/*macro definitions of PIR motion sensor pin and LED pin*/
#define PIR_MOTION_SENSOR 2//Use pin 2 to receive the signal from the module


void setup()
{
    pinMode(PIR_MOTION_SENSOR, INPUT);
    Serial.begin(9600);  

}

void loop()
{
    if(digitalRead(PIR_MOTION_SENSOR))//if it detects the moving people?
        Serial.println("Hi,people is coming");
    else
        Serial.println("Watching");

 delay(200);
}

Note

The detecting distance and holding time can be adjusted by adding two extra potentiometers on board. For the details please refer to the V1.2 Eagle below. The module can also be set as retriggerable or un- retriggerable by changing the jumper hat.

The result should be like:

Play with Raspberry Pi

Hardware

  • Step 1. Prepare the below stuffs:
Raspberry pi GrovePi_Plus Grove - PIR Motion Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.

  • Step 3. Connect the sensor to D8 port of GrovePi_Plus.

  • Step 4. Connect the Raspberry to PC through USB cable.

Software

Tip

In this wiki we use the path ~/GrovePi/ instead of /home/pi/Desktop/GrovePi, you need to make sure Step 2 and Step 3 use the same path.

Note

We firmly suggest you to update the firmware, or for some sensors you may get errors.

  • Step 3. Git clone the Github repository.
cd ~
git clone https://github.com/DexterInd/GrovePi.git
  • Step 4. Run below commands to use the PIR Motion Sensor to monitor the movement of people.
cd ~/GrovePi/Software/Python
sudo python grove_pir_motion_sensor.py

Here is the grove_pir_motion_sensor.py code.

import time
import grovepi

# Connect the Grove PIR Motion Sensor to digital port D8
# SIG,NC,VCC,GND
pir_sensor = 8

grovepi.pinMode(pir_sensor,"INPUT")

while True:
    try:
        # Sense motion, usually human, within the target range
        if grovepi.digitalRead(pir_sensor):
            print 'Motion Detected'
        else:
            print '-'

        # if your hold time is less than this, you might not see as many detections
        time.sleep(.2)

    except IOError:
        print "Error"

The result should be like:

pi@raspberrypi:~/GrovePi/Software/Python $ sudo python grove_pir_motion_sensor.py

-
-
-
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
Motion Detected
-
-

Resources

Tech Support

Please do not hesitate to contact techsupport@seeed.cc if you have any technical issue. Or submit the issue into our forum.