On your Raspberry Pi, the Arduino board
should now appear as /dev/ttyACM0 or /dev/
ttyUSB0. You can verify this by typing ls /dev/
tty* into the Pi terminal.
Now run the Pi Smart Cam code, arduino_
comms.py. This Python application receives data
via serial comms from the Arduino (Figure
J
).
The output seen in the terminal prints the value
1, representing the PIR sensor state being HIGH,
meaning motion is detected!
Note that the baud rate is set to 9600 (Figure
K
).
6. 3D PRINT THE CAMERA HOUSING
If you have access to a 3D printer, you can
optionally build your own camera chassis (Figures
L
,
M
, and
N
) to house the camera, PIR sensor,
Arduino, and Raspberry Pi. You can find the 3D
parts and assembly details on the GitHub repo.
Please feel free to contribute any modifications or
accessories to the repo!
SOMEONE’S AT THE DOOR!
Your Pi Smart Cam is ready to keep an eye on
things, indoors or out the window (Figures
O
and
P
). Now lets set up an action.
SENDING A NOTIFICATION VIA EMAIL
In this example, we’ll send a notification to our
email with a camera frame capturing the exact
motion detected (Figure
Q
).
The example code email_notification.py (Figure
R
) sends emails to a target address including
the attached camera frame, subject line, and
message as part of the body using the SMTP
Python library. SMTP is a protocol that handles
sending emails between mail servers.
To configure your email notification, the
following fields can be found in main.py:
pi_email = "<from-email>"
pi_app_password = "<app-password>"
pi_port = 465
pi_host = "smtp.gmail.com"
notication_recipient = "<to-email>"
NOTE: If you want to send email
notifications via Gmail, enable 2FA and
use App Passwords instead of storing the
password as plain text. Find the latest
information on the GitHub repo.
PROJECTS: Pi Smart Security Camera
J
K
L
M
N
102 makezine.com
M82_098-103_SmartPiCam_F1.indd 102M82_098-103_SmartPiCam_F1.indd 102 7/12/22 11:28 AM7/12/22 11:28 AM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset