Grove - Digital PIR Sensor
PIR sensor is an IR sensor to detect human motions. This Grove Digital PIR Sensor is the cheapest PIR sensor in the PIR families, however, it is able to give a quick response and generate a high signal from the "sig" Pin.
With the Grove interface, the Grove digital PIR Sensor is easy to be plugged and played. And it doesn't need any Arduino Library.
Features
- Budget-friendly: less than 3 dollars
- Intuitive: detect motion and output with only ‘high’ and ‘low’ digital signals
- Simple: no external arduino library required
- Interface: Grove
Specification
Item | Value |
---|---|
Voltage range | 3V–5V |
Detecting angle | 100 degree |
Detecting distance | 3.2m-12m |
Response time | < 1s |
Working temp | -20-85 C |
Interface | Grove |
Dimensions | 20mm 20mm 11.5mm |
Weight | 3g |
Battery | Exclude |
Platform Supported
Arduino | Raspberry Pi |
---|---|
Getting Started
Getting Started with Arduino
Materials Required
Seeeduino XIAO | Grove Breadboard | Grove Digital PIR Motion Sensor |
---|---|---|
Get one now | Get one now | Get one now |
Hardware Connection
The Grove interface on the breadboard and on the Grove digital PIR Sensor are connected by the Grove cable.
Softwawre
- Step1 Copy the code below to the Arduino IDE and upload. If you do not know how to update the code, please check How to upload code.
#define digital_pir_sensor 5 // connect to Pin 5
void setup()
{
Serial.begin(9600); // set baud rate as 9600
pinMode(digital_pir_sensor,INPUT); // set Pin mode as input
}
void loop()
{
bool state = digitalRead(digital_pir_sensor); // read from PIR sensor
if (state == 1)
Serial.println("A Motion has occured"); // When there is a response
else
Serial.println("Nothing Happened"); // Far from PIR sensor
}
- Step2 Open the Serial port and you will see the value changing when you take a motion around the PIR sensor.
Getting Started with Raspberry Pi
Materials Required
Raspberry Pi 4B(4GB) | Grove Base Hat for Raspberry Pi | Grove Digital PIR Motion Sensor |
---|---|---|
Get one now | Get one now | Get one now |
Hardware Connection
Connect the PIR sensor with "D5" on the Grove Base Hat.
Code
- Step 1 Update the system verion of Raspberry Pi.
sudo apt-get update
- Step 2 Install the wiringPi.
sudo pip install wiringPi
If you use Pi 4, please select the version of wiringPi
sudo pip install wiringPi==2.52.0
- Step 3 Get the right Pin you are connecting with.
gpio readall
here comes a table, find the Pim definition of the Pin 5 in wiring definition, in this demo, the pin definition is 21.
gpio read 21
You can read the value from the PIR sensor, when there is a motion, the value is "1", otherwise. the value is "0".
Schematic Online Viewer
Resource
- [PDF] BS312 Specification
- [PDF] Hardware schematic
Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.