PIR Project Notes


I’m working on a project similar to a security camera with a Raspberry Pi NoIR Camera Module v2 and a FLIR Lepton 3.5 on a purethermal 2.

I am somewhat new to this and am not sure how to proceed. I need to have the program trigger from a motion detector (PIR) attached to a GPIO pin and activate either the camera or FLIR depending on the time of day. I also need the system to store 5 jpegs a second of the stream while there is still motion. I am currently attempting to run video and use gstreamer to convert certain frames to jpeg because this seems more reliable than the still features. Any help would be appreciated.

Does anyone know how to capture and switch between these cameras as well as continue the stream while there is motion?

 New contributor
  • forgot to mention max resolution required is 640×480 – Ben0547 5 hours ago
  • Yes, so I found a cheapy Logitech webcam with 640 x 480 pixels can do the job well. Even AlphaGo cannot handle higher resolution than a chess board. RpiCamV2 with 3280 × 2464 pixels is a ridicuious overkill. You need to reduce RpiCam to 640×480 to do AI (and from RGB to black and white, my goodness!). That was why I abandoned RpiCam and switched to LogiTechCam. – tlfong01 1 hour ago    



Let me summarize your project.

  1. You have two cameras, one day camera, another, night camera.
  2. You have one PIR sensor, connected to Rpi which gets alerted if a naughty cat comes in.
  3. If it is day time, Rpi switches on camera and starts streaming video, extracts to 5 jegs a second and stops as soon as the thing has left.
  4. Similarly the night camera at night.

Short Answer

Some time ago I used Rpi, Rpi Camera, and also cheap Logitech web cameras to do similar things and found many open software tools and libraries helpful.

Now I have learnt how to use python to interface real time clock DS3231. Perhaps I can do system integration this time, starting with PIR. Perhaps I can also add Google Tensor Flow cat face detection, …

pir modules

web cam and mon


AI to identify cats 2012 and 5000 species 2017 – Dave Gershgorn 2017apr11

Cats🐱 vs Dogs🐶 Leveraging Convolutional Neural Networks and Google Colab Free GPU – Greg Surma 2018nov18

Edge TPU – cloud google

Coral Local/Offline AI (Mendel/Debian, Tensor Flow Lite, Python) – Google

Edge TPU USB Accelerator (Raspberry Pi, Debian) – USD$74.99https://coral.withgoogle.com/products/accelerator/ https://coral.withgoogle.com/tutorials/accelerator-datasheet/

Update 2019apr11htk1049

More References

Adafruit PIR Sensor Tutorial – Introducing PIR https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/overview

Adafruit PIR Sensor Tutorial – Connecting to PIR https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/connecting-to-a-pir

Adafruit PIR Sensor Tutorial – Testing PIR https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/testing-a-pir

PIR BISS00012 Micro Power PIR Motion Detector IC Datasheet – Shanghai JX 2005http://www.ladyada.net/media/sensors/BISS0001.pdf

PIR BISS00012 Micro Power PIR Motion Detector IC Datasheet in Chinese – Shanghai JX 2005http://www.ec66.com/market/sheet/biss0001.pdf

AliExpress PIR sensor module catalog https://www.aliexpress.com/w/wholesale-pir-sensor-module.html

TaoBao PIR Sensor Module Catalog https://risym.tmall.com/search.htm?q=%C8%CB%CC%E5%B8%D0%D3%A6%C4%A3%BF%E9+&navigator=all&_input_charset=&spm=a21bp.7806943.20151106.1

TaoBao HC-SR501 PIR Module CN¥3.60 https://item.taobao.com/item.htm?spm=a312a.7700824.w4002-18130655753.30.569b21fci4bMs6&id=589581993055

/ to continue, …

  • Yes that is a similar setup, i’m just don’t understand exactly how to even start with the python code to integrate the motion sensor and determine the cameras. I have some basic command lines that seem to be running but typically for these cameras to initialize you set a run time to they don’t run continuously while there is movement – Ben0547 1 hour ago
  • Thank your for confirmation. Let us first see how to talk to PIR using python, and forget the cameras now. – tlfong01 1 hour ago   
  • I had some basic code that would tell me if there was currently movement or not. I imagine with this I could use a while to run the cameras I’m just not certain how to make the cameras run for the entirety and then encode the frames. – Ben0547 43 mins ago
  • import RPi.GPIO as GPIO<br/> import time<br/> GPIO.setwarnings(False)<br/> GPIO.setmode(GPIO.BCM)<br/> GPIO.setup(4, GPIO.IN)<br/> <br/> while True:<br/> i = GPIO.unput(4)<br/> if i == 0:<br/> print”Movement”, i<br/> if i == 1:<br/> print”No Movement”, i<br/> time.sleep(1)<br/> – Ben0547 42 mins ago
  • Ah, I forgot how the PIR thing works. So I am asking Lada Ada for help. See your later. learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/… – tlfong01 24 mins ago    

Categories: PIR

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: