How to Connect a PIR Sensor to an Arduino Uno

Spread the love

We may earn money reviewing products from the affiliate links on this site. Thank you all!

Ever wanted to come up with a project that will detect when an individual is in your room? You can achieve this with utmost ease while using PIR (passive infrared) motion sensor and come up with projects like a burglar alarm as well as automated appliances. In this article, we shall be discussing how to connect the PIR sensor to Arduino Uno.

We shall be discussing how to design motion sensors with Arduino and then design burglar alarms. This particular system will detect whenever an intruder is in a room and then send signals to your Arduino. Once that is done, the Arduino will create an alarm which will sound with the use of the buzzer to help scare the burglar.

How motion sensors work

Understanding the way in which motion sensors operate is vital for all DIY enthusiasts. The PIR motion sensor features infrared detector, Fresnel lens, and supports detection circuitry. Usually, the lens of a sensor is designed to focus on infrared radiation that is present within it towards an infrared detector. Since human bodies produce infrared heat, a motion sensor will be able to detect it. 

Furthermore, your sensor will output 5-volt signals for approximately one minute once the sensor detects the presence of an individual. Furthermore, it offers an incredible detection range of approximately 6 to 7 m; furthermore, it is very sensitive.

Once your PIR motion sensor senses an individual, it will output 5-volt signals to your Arduino and then triggers an interrupt. To define what an Arduino needs to do when detecting intruders, you should consider designing your alarm sound using the piezo buzzer. 

Once your sensor detects the intruder, it will trigger alarm sound via the buzzer. Your piezo buzzer will be activated through an Arduino with the use of PWM signal (pulse width modulation).

Connecting your PIR sensor to an Arduino Uno

All the connections needed when it comes to interfacing Arduino Uno motion sensors along with a piezo buzzer tends to be pretty much straight forward. You will need to connect a motion sensor with the Arduino Uno by connecting GND and VCC on your sensor to GND and 5-volt pins of your Arduino. 

Once that is done, you will go ahead and join an output-signal pin on your motion sensor with the digital pin 2 of your Arduino signal.
Once you have hooked up your Arduino motion sensor, go ahead and connect your piezo buzzer with the system. 

In order for you to achieve this, you will first connect a negative terminal in your buzzer which is often the black wire to the GND pin of your Arduino, and then the positive wire which is the red wire should be connected to digital pin 9 of your Arduino. The whole process is relatively easy and can be achieved by any individual, including newbies.

Uploading code for your Arduino motion sensor along with the piezo buzzer

With your Arduino Uno set up, you should go ahead and test it using the piezo buzzer and see how it works. In order to achieve this, you will first have to download the right code for your Arduino Uno motion sensor. 

Once that is done, you will go ahead and open the code in an Arduino IDE and then upload the code to an Arduino Uno. Go ahead and assess if it is working correctly by opening your serial monitor-115200bps setting of the baud rate.

You should note that your motion sensor might take approximately one minute before it becomes calibrated with its surrounding once its turn on. The sensor will become activated when the intruder stands within 6 to 7 m radius of your Arduino Uno PIR sensor. 

Once that is done, your buzzer will start making an alarm sound; the intruder detected will then be printed on a serial monitor. Furthermore, your sensor output (0V) LOW signal within a minute whenever you are not near your PIR sensor radius. 

Usually, the delay time, as well as the sensitivity of your PIR motion sensor, can be adjusted depending on the PIR model you are using. It is best that you adjust your PIR sensor correspondingly until you attain your sweet spot.


When your PIR sensor detects an individual, it will output the HIGH-signals to the digital pin-2 in your Arduino. 

This will then immediately trigger an interrupt function known as intruder_detect(). The best part is that you might consider programming your Arduino to perform something once an intruder is detected by editing this particular function intruder_detect(). 

It will print the intruder detected and then three times run a function known as siren(). Siren() function consists of code that is required to design alarm sounds in your piezo buzzer and a speaker. Usually, it achieves this through writing a PWM signal of different periods along with frequencies to a piezo buzzer.

Furthermore, you will come to notice that you will experience a delay that is linked with the sensor after every detection. You might adjust the delay depending on the type of sensor you are using. This Arduino Uno motion sensor is ideal for designing burglar alarms along with home automation systems and simple gadgets which prevent people from invading your space.

Final verdict

As a DIY enthusiast, understanding how to connect the PIR sensor to Arduino Uno is vital for designing several critical projects, such as creating a burglar alarm. The process involved in connecting a PIR sensor to an Arduino Uno is relatively easy, and you can achieve it with utmost ease once you adhere to the tips discussed in this article. 

You can connect your Arduino Uno to PIR to create a simple circuit which detects movement; you can incorporate an LED light which will turn on once motion is detected. Depending on the PIR sensor you are using, you might consider adjusting the detection radius, which will best suit your needs.

As we come into conclusion, we hope that you find this article beneficial as you connect the PIR sensor to the Arduino Uno. We hope that this article has answered the question on how to Connect PIR Sensor to Arduino Uno.

About the Author Dan

Just a random guy who likes to build things. Providing tool knowledge, appliance/device testing tips, and DIY project info in an easy-to read & non-intimidating style.