How to Use a PIR Motion Sensor with Raspberry Pi

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 มิ.ย. 2019
  • This raspberry pi tutorial shows how to use a PIR sensor on the raspberry pi model B+. It explains how to wire the sensor into a breadboard using the raspberry pi's GPIO pins. It then shows how to use python code to toggle a green LED on and off based on detected motion.
    Playlist: • Raspberry Pi Tutorial ...
    Parts Used:
    PIR Sensor: www.amazon.ca/OSEPP-Passive-I...
    Supply Kit (Everything you Need): www.amazon.ca/UNIROI-Breadboa...
    Jumper Wires: amzn.to/2WxlSsx
    Bread Board:amzn.to/2WuWzYd
    LED: amzn.to/2MQ1u1J
    Resistor: amzn.to/2XyUneF
    Raspberry Pi B+: amzn.to/2Wt0QeR
    ◾◾◾◾◾
    💻 Enroll in The Fundamentals of Programming w/ Python
    tech-with-tim.teachable.com/p...
    📸 Instagram: / tech_with_tim
    🌎 Website techwithtim.net
    📱 Twitter: / techwithtimm
    ⭐ Discord: / discord
    📝 LinkedIn: / tim-rusci. .
    📂 GitHub: github.com/techwithtim
    🔊 Podcast: anchor.fm/tech-with-tim
    💵 One-Time Donations: www.paypal.com/donate/?token=...
    💰 Patreon: / techwithtim
    ◾◾◾◾◾◾
    ⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
    Tags:
    - Tech With Tim
    - Raspberry Pi Tutorial
    - Raspberry pi motion sensor
    - Pir sensor raspberry pi
    #raspberrypi #rasberrypipython

ความคิดเห็น • 87

  • @TechWithTim
    @TechWithTim  5 ปีที่แล้ว +4

    Pick up a PIR Sensor here: th-cam.com/users/redirect?v=Tw0mG4YtsZk&event=video_description&redir_token=95KdJupB9A12BXjHC4NTc-fQL7h8MTU2MDQ2ODM3N0AxNTYwMzgxOTc3&q=https%3A%2F%2Fwww.amazon.ca%2FOSEPP-Passive-Infrared-Components-PIR-01%2Fdp%2FB01ISMW0TU%2Fref%3Dsr_1_14%3Fkeywords%3Draspberry%2Bpi%2Bpir%26qid%3D1560298881%26s%3Delectronics%26sr%3D1-14%26_encoding%3DUTF8%26tag%3Dtechwithtim08-20%26linkCode%3Dur2%26linkId%3D0888f8635ee901445b780beb7ca96088%26camp%3D15121%26creative%3D330641

  • @OnleySkyeAlt
    @OnleySkyeAlt 3 ปีที่แล้ว +43

    this helped me with my school project. i made a motion sensor that says bruh out of a speaker when it detects motion

    • @lizardking4944
      @lizardking4944 2 ปีที่แล้ว +1

      did u share this on your github account dude?

    • @alex59292
      @alex59292 ปีที่แล้ว +1

      @@lizardking4944 bro this is simple to do

    • @lizardking4944
      @lizardking4944 ปีที่แล้ว

      @@alex59292 this is none of your business bro

    • @alex59292
      @alex59292 ปีที่แล้ว +1

      @@lizardking4944 the video shows the hardest part of his project all it is is simple code

  • @MohsinKhan-rv7jj
    @MohsinKhan-rv7jj 3 ปีที่แล้ว +1

    One of the best videos you will find on Internet for PIR sensor

  • @julyapetrenchuk7866
    @julyapetrenchuk7866 5 ปีที่แล้ว +12

    Awesome that you are using python for it

  • @kyleanderson3633
    @kyleanderson3633 5 ปีที่แล้ว +3

    Great video! Very clear and well explained.

  • @PhilinQQ
    @PhilinQQ 5 ปีที่แล้ว

    Really interesting and cool tutorial

  • @Beeckey
    @Beeckey ปีที่แล้ว

    This is the best explanation ever! Thank you soo muchhh!!!

  • @dimitardimitrov6936
    @dimitardimitrov6936 4 ปีที่แล้ว +2

    Thanks for the nice and understandable video! My question is (and maybe it's a good topic for your next video) how can I get information over internet about the pir status and/or history? i.e. "current status", "last time and date it was triggered", "count of the triggers over a period" , " where the pir status history is to be stored, and auto overwritten every 2 months (for example)", etc... The idea is to know the activity at home, when I'm faaaar far away. Is there a mobile app that you know will work?

  • @motzs1016
    @motzs1016 4 ปีที่แล้ว

    Thanks for this tutorial

  • @agyeirichmondowusu9670
    @agyeirichmondowusu9670 3 หลายเดือนก่อน

    Your tutorial is the best. Please do more of these

  • @jhred3315
    @jhred3315 ปีที่แล้ว

    Hey Tim. I really like your tutorials. Can you make more about raspberry pi since yours are most easy to understand especially the plugging part.

  • @patrykperwenis4348
    @patrykperwenis4348 2 ปีที่แล้ว +1

    very good tutorial

  • @ernestoloredo2618
    @ernestoloredo2618 4 ปีที่แล้ว

    Thank you so much!!! God bless

  • @YouKnowMeDuh
    @YouKnowMeDuh 2 ปีที่แล้ว +1

    Great tutorial. You're very clear and to the point. Thanks a ton.

  • @matiu7276
    @matiu7276 5 ปีที่แล้ว +1

    Can you use regular phone charger that has 5V and 2A to power this raspberry? It's a fast charger too so it has 9V and 1.7A written in upper bar. I'm about to buy Raspberry 3 A+ so I don't want to destroy it too fast :)

  • @Enigmaafk
    @Enigmaafk 3 ปีที่แล้ว

    i like this method, can you link this to an lcd and let it display motion detected. thanks

  • @loicsigni1613
    @loicsigni1613 3 ปีที่แล้ว +1

    Great video. I wanna use the same PIR sensor for this small door greeting robot I'm building,. My question is:
    If I program the Raspberry Pi and disconnect it from my computer would it still work as long as I am feeding it with electrical power?

    • @seth8811
      @seth8811 2 ปีที่แล้ว

      You need to connect batteries then

  • @brentrusche2056
    @brentrusche2056 6 หลายเดือนก่อน

    @TechWithTim
    Great tutorial. I too want to make a surveillance system using an RPi and multiple PIR sensors. However, I am not quite certain as to the wiring and code for using multiple PIR sensors. I would really appreciate an expanded tutorial on using multiple PIR sensors on a single RPi.
    Thanks in advance!

  • @nguyenmax277
    @nguyenmax277 3 ปีที่แล้ว +7

    how can we add a speaker instead of an LED

  • @SuperAn0nymus
    @SuperAn0nymus 3 ปีที่แล้ว +1

    Wow!! amazing explanation!! ..could you tell why did you use resistor instead of a jumper cable?

    • @krypton1142
      @krypton1142 ปีที่แล้ว

      the resistor is there to make sure not too much current passes through the LED and explodes it.

  • @cosming940
    @cosming940 4 ปีที่แล้ว +1

    The Resistor that you use is 100 Ohm ?

  • @Duriel1000
    @Duriel1000 4 ปีที่แล้ว +4

    is the function "wait_for_motion()" a built in function from the Sensor import?

    • @Ghillis_Peyton
      @Ghillis_Peyton 10 หลายเดือนก่อน +1

      yeah, its a method of the MotionSensor Class

  • @katefernandez240
    @katefernandez240 4 ปีที่แล้ว

    Hi! Do you know how to connect multiple PIR? Thanks

  • @wuyanchu
    @wuyanchu 5 หลายเดือนก่อน

    very nice tutorial, thx and god bless you and the world.. 來自香港的祝福, regards from hong kong ^_^

  • @darrenstorey4558
    @darrenstorey4558 3 ปีที่แล้ว

    With the pi4 having a 5v output, using this tutorial as an example, is it possible for it to power an LED strip instead of an LED bulb? I am wanting to use the PIR in a magic mirror where whenever someone stands in front of the mirror, the PIR triggers and lights up the LED strips to act as a mood light around the mirror itself. ps I am a total NOOB so any help is much appreciated

  • @budgetpresents802
    @budgetpresents802 3 ปีที่แล้ว +1

    Can u use other models of rasberry pi and if yes what others?

  • @hoangquyla4516
    @hoangquyla4516 4 ปีที่แล้ว +2

    Hi Tim can you make a video on how to use raspberry pi in order to detect the temperature and humidity

  • @sainco3036
    @sainco3036 5 ปีที่แล้ว

    thanks.

  • @James-sh1lw
    @James-sh1lw 3 ปีที่แล้ว +1

    Hey Tim I know this video is kinda old now but hopefully you're checking comments. Do you think this will be ok opposite my window? I'm building a magic mirror with my raspberry pi and an LED monitor but dont want the monitor constantly running, so I want it to turn on with motion detection. From the angle it wont see anything moving outside but the sun moving around during the day does changed the light levels in the room. What do you reckon? Do you also know how to turn on/off the HDMI port with a motion sensor?

    • @SprocketN
      @SprocketN 3 ปีที่แล้ว +1

      I believe the detector can’t ‘see’ through glass, so it shouldn’t detect anything moving outside.
      They’re not expensive so buy one and try it 😀

    • @James-sh1lw
      @James-sh1lw 3 ปีที่แล้ว

      @@SprocketN thank you!

  • @--Jonathan09--
    @--Jonathan09-- 2 ปีที่แล้ว

    awesome👍

  • @nickaf4204
    @nickaf4204 4 ปีที่แล้ว +1

    Is there a way to connect this to pi without the use of a breadboard?

  • @mandeepubhi4744
    @mandeepubhi4744 5 ปีที่แล้ว

    Awesome

  • @bernielovell2197
    @bernielovell2197 3 ปีที่แล้ว

    I bought a power trigger water spray hoping to detect the crapping cat who visits my garden. It worked fine with a cheap air-freshener detector but, to was so weak that I really needed a PIR sensor. This was much more difficult to make work. It either never worked or It worked with no stopping. How about making one on this problem?

  • @brighterryu2465
    @brighterryu2465 2 ปีที่แล้ว

    good example

  • @bigbad123321
    @bigbad123321 ปีที่แล้ว

    I've got a question. Can you run this while simultaneously running a temperature reading with a temp sensor and get the programme to print out both "motion detected/motion stopped" and also have it printing the temperature every X amount of seconds aswell?

    • @Ghillis_Peyton
      @Ghillis_Peyton 10 หลายเดือนก่อน

      yes, but you would need to use asyncio or threading to run both at once

  • @raidsagr3263
    @raidsagr3263 4 ปีที่แล้ว +1

    How can i programme this to find out the total duration of the light was turned on the last 6hrs for example?
    Thank you very much

    • @grog8164
      @grog8164 3 ปีที่แล้ว +1

      the light is on during motion detected until motion stop so you could basically have a top variable `light_on_duration_sec` in which you add the time elapse between motion detected until motion stop. Your `light_on_duration_sec` is your only critical data so either you count on your pie to stay alive during the day either your persist the information on the disc. For your "on the last 6hrs" then it's up to you to program it using your pie datetime and `ìf` condition

  • @itzkeyz2526
    @itzkeyz2526 3 ปีที่แล้ว

    Is there a way to display the time motion is detected

  • @rishivinukonda
    @rishivinukonda 3 ปีที่แล้ว

    Do you think you do it with java?
    Cause I don’t know python

  • @funkygetaways
    @funkygetaways 3 ปีที่แล้ว

    Is a breadboard required for this?

  • @jungleviper
    @jungleviper ปีที่แล้ว

    Can I use this to turn some led lights on and off

  • @Randy2747
    @Randy2747 4 ปีที่แล้ว

    Could you please help me out and make a code that I can use the relay, PIR, and raspberry pi but have the light (or anything else that is plugged in to the relays) set on a timer? I woukd like to put lasers in my game room and when someone walks into the room the lasers will be by the ceiling and come on for a duration of the time I set. Could you please help me out and either make a video of the timer added or post the code here? Please 😉😁

  • @crownz936
    @crownz936 4 ปีที่แล้ว +4

    I knw I’m late but my sensor picks it up but doesn’t stop the led light. Pls reply

  • @bshara83
    @bshara83 11 หลายเดือนก่อน

    Hello, could you help me write code for bi-deractional people counter using 2 sensors where when objects pass first then the second sensor will count+1, or the second then the first sensor will count -1. And record the In and Out and current occupies the room to SQL DB, please 👏

  • @chrismunson5513
    @chrismunson5513 3 ปีที่แล้ว

    I want to run this exact setup, but have it with a photo slideshow, so it will only play when someone is present? Anyone with exp please help. Brand new to pi OS and lineage. First project with pi zero

  • @ProgrammerSheep
    @ProgrammerSheep 5 ปีที่แล้ว +1

    How are you screen recording?!?!

  • @AnkitaMalusare-nd8xv
    @AnkitaMalusare-nd8xv 9 หลายเดือนก่อน

    Nice Video
    But I have a doubt our LEDs Motion Detected but Motion Does Not Stopped

  • @mrlevo27
    @mrlevo27 ปีที่แล้ว

    Hallo I get a montion startet sensor when I pulled of the sensor cable by accident. What could be the problem

  • @ayy.mp4
    @ayy.mp4 3 ปีที่แล้ว

    How do I close the script properly?

  • @dharmareddy3636
    @dharmareddy3636 4 ปีที่แล้ว

    Can I have the link of raspberry is that you are using

    • @anghel332
      @anghel332 4 ปีที่แล้ว

      Search for raspberry pi 4 model b

  • @sahilhadke
    @sahilhadke 3 ปีที่แล้ว

    I'm here to stop a freaking cat from pooping in our balcony.

  • @ProgrammerSheep
    @ProgrammerSheep 5 ปีที่แล้ว +3

    Yeah just take out the resistor LOL

  • @sainco3036
    @sainco3036 5 ปีที่แล้ว

    perhaps at this rate we will reach robotics and the study grew (by the way there is a lot of Python).

  • @ProgrammerSheep
    @ProgrammerSheep 5 ปีที่แล้ว

    Why not Arduino

    • @abhichoudhary4518
      @abhichoudhary4518 3 ปีที่แล้ว +2

      Arduino can be used for this project, and in my opinion, would be faster, but this video can be for someone who doesn't have an Arduino, or if someone wants to incorporate a PIR sensor in their Raspberry pi project but don't know how to

  • @AnkitaMalusare-nd8xv
    @AnkitaMalusare-nd8xv 9 หลายเดือนก่อน

    LEDs Motion Not Detect Exactly

  • @heinzbeckenbauer243
    @heinzbeckenbauer243 5 ปีที่แล้ว +2

    Very good video but can you turn off the auto focus. Thank you :)

    • @TechWithTim
      @TechWithTim  5 ปีที่แล้ว +3

      Why would I turn it off? Then you wouldn’t be able to see anything

    • @heinzbeckenbauer243
      @heinzbeckenbauer243 5 ปีที่แล้ว

      @@TechWithTim I meant you may could do manuell focus so it doesnt swich all the time.

    • @TechWithTim
      @TechWithTim  5 ปีที่แล้ว +2

      Ya no that would not be possible 😂 constantly spinning the wheel, no thanks

    • @heinzbeckenbauer243
      @heinzbeckenbauer243 5 ปีที่แล้ว

      @@TechWithTim ok I understand. But still great video

  • @Randy2747
    @Randy2747 4 ปีที่แล้ว +1

    this was a FAIL for me..I figured i would try my first script with my new raspberry pi 3 and i got a error cannot import name 'led' from gpiozero...why?
    Edited..I figured it out.......I didnt have capital letter :-)

    • @sm-vr6kn
      @sm-vr6kn 2 ปีที่แล้ว

      What all things are included in the supply kit?

  • @wuyanchu
    @wuyanchu 5 หลายเดือนก่อน

    very nice tutorial, thx and god bless you and the world.. 來自香港的祝福, regards from hong kong ^_^

  • @budgetpresents802
    @budgetpresents802 3 ปีที่แล้ว

    Can u use other models of rasberry pi and if yes what others?

  • @budgetpresents802
    @budgetpresents802 3 ปีที่แล้ว

    Can u use other models of rasberry pi and if yes what others?

  • @budgetpresents802
    @budgetpresents802 3 ปีที่แล้ว

    Can u use other models of rasberry pi and if yes what others?

  • @budgetpresents802
    @budgetpresents802 3 ปีที่แล้ว +1

    Can u use other models of rasberry pi and if yes what others?

    • @SprocketN
      @SprocketN 3 ปีที่แล้ว +1

      Yes, it will work with all Pi models.