How to Use the Raspberry Pi Camera And PIR Sensor to Send Emails

Raspberry Pi Camera And PIR Sensor to Send Emails
Introduction :
In this tutorial, I’ll show you how to send emails containing pictures using a Raspberry Pi4 and a  motion detector and the Python programming language. We will use a PIR motion detection sensor and whenever motion is detected, the Raspberry Pi4 Camera will take a picture and send an email with the picture attached.
In this tutorial I divide this project some step if you flow this step with me i hope you can do this
You have to need some change in your google account flow this step
  1. Login to your Gmail account by entering your login credentials.
  2. Click on your profile picture and then click on “Google account”.
  3. Under “Sign-in and Security” click “Connected apps and sites”.
  4. Click “Allow less secure apps” to turn it on.(By Default its Turn off)
  1. Step-2
    1. Components Required for  Raspberry Pi Camera And PIR Sensor to Send Emails
  1. Raspberry Pi 4 Model B
  2. PIR Sensor
  3. 5V Buzzer
  4. Connecting Wires
  5. Mini Breadboard
  6. Power Supply

Circuit Diagram

The following Fritzing based images show all the connections with respect to the PIR Motion Sensor using Raspberry Pi4
How to Use the Raspberry Pi4 Camera And PIR Sensor to Send Emails
How to Use the Raspberry Pi4 Camera And PIR Sensor  to Send Emails

Circuit Design:

Connect the VCC and GND pins of the PIR Motion Sensor to +5V and GND pins of the Raspberry Pi4. Connect the DATA Pin of the PIR Sensor to GPIO24 of the Raspberry Pi4.
A 5V Buzzer is connected to GPIO20  And Raspberry pi4 Camera Connect to the PI Connector Slot. The other pin of the buzzer connected to GND.

The Python Code to Send Emails

Before running the code, make sure the sender and receiver email addresses and the password of the email sender are all entered.

The code will read the output from the sensor and, upon detecting motion, will capture an image and save it on the database folder.

When you run the code for the first time, it will automatically create the folder. Once the camera captures an image, the image will be attached in the email and sent to the sender’s address.

My Previous Project :

 98 total views,  1 views today