element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Spy Nerd
  • Challenges & Projects
  • Project14
  • Spy Nerd
  • More
  • Cancel
Spy Nerd
Blog Pi Spy Audio Recorder - part 2 - PIR sensor
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Spy Nerd to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 7 Nov 2021 5:33 PM Date Created
  • Views 5815 views
  • Likes 2 likes
  • Comments 0 comments
  • spynerdch
  • audio recording
  • pir
  • raspberry pi zero
  • spy nerd
  • pyaudio
Related
Recommended

Pi Spy Audio Recorder - part 2 - PIR sensor

carmelito
carmelito
7 Nov 2021

This is the second blog post for the Pi Spy Audio Recorder project, in this blog post I am adding a PIR sensor to the Raspberry Pi Zero W, to detect a motion in the room, so that the spy audio recorder can start recording for a few minutes, and then send the recording to the spy via an email.

image

 

As part of the build/circuit, as you see in the picture above

  • the PIR sensor signal pin, the yellow wire is connected to GPIO 4 on the raspberry Pi zero
  • and the USB mic is connected to the Pi using a micro USB OTG cable.

 

For setting up the Mic on Raspberry Pi OS (2021-05-07-raspios-buster-armhf-lite image), please go to the previous blog post at - Pi Spy Audio Recorder - part 1

 

Once you done installing pyaudio and running the python program in the previous blog, to record audio for 60 seconds, check if every thing is fine with your PIR sensor by running this simple program below. Basically you will have to check if motion is detected, by the sensor.

 

from gpiozero import MotionSensor
from time import sleep


pir = MotionSensor(4)
while True:
        if pir.motion_detected:
                print("Motion Detected")
        else:
                print("No Motion")
        sleep(1)

 

Now, if you are using your brand new PIR sensor for the first time, and you are continuously get "No Motion" , even tough you are waving your hand in front of the PIR sensor, you may have to adjust the two potentiometers  on your PIR sensor as you see in the picture below. To adjust the two pots you will need a regular small screw driver. To start off, make sure that trigger pot is to the left, which means lower trigger time, and the sensitivity pot in the middle.

image

 

Now, once you have successfully got "Motion Detected", in you Pi home directory create a recordings folder, using

mkdir recordings

 

Once done, download the python program file attached and FTP it to your Pi Zero W. And, run it using

sudo python3 spyRecordPIR.py

image

 

Now, instead of the above output, if you run into an error for your email setup, something on the lines of -

File "/usr/lib/python3.7/smtplib.py", line 642, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8

 

This means you will have to login to your from_email and go to https://myaccount.google.com/lesssecureapps  , to enable the less secure option, for the SMTP sending email method to work, and to get rid of the above error.

image

Here is an email with the audio recording received, once motion is detected by the PIR sensor.

image

 

 

 

Here is a quick demo video of the Pi Spy Audio Recorder in action.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Attachments:
spyRecordPIR.zip
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube