Introduction
In this tutorial, I am going to show you how to build a simple application that detects motion and sends notifications to the your smart phone using a Raspberry Pi and camera module. If there is something or someone moving in the camera setup’s field, you will get notified to your phone or web browsers.
The notification comes with text, still image, and video that you can view it right on iOS or Android. The application is pretty simple. It utilizes the free software and services such as picamera, ffmpeg, and pushbullet.
I will walk you through the architecture, flowchart, and explain the main Python functions. At the end of this video, you can build your own application or customize the already built one as you wish.
Let’s start!
Hardware
- Optional: Heat sinks
- Optional: Simple case or Fancy Case
Or you can buy all-in-one set here.
Specification
This section explains the specification of application including app structure, and general flowchart. You will have a clear vision about what application does.
Application Structure
There are 3 actors that play together to build up the application:
- (1) Raspberry Pi & camera module as the data source that continuously scan for motion and recording video at the same time.
- (2) Pushbullet as the message-broker to send messages (text, still image, and videos) back and forth between Raspberry Pi and Mobile/Web
- (3) Mobile/web acts as “notifyee” who receives the still image and video of motion. The communication is two ways though. It means you can send a command from mobile or web to Raspberry Pi for particular action such as “@snap” (for instantly take a photo) or “@check” (to get current system information of Pi).
General Flowchart
When the script launches, it takes 2 seconds to warm up the camera to make sure everything works properly. Then it jumps right into motion scanning. If moving happens, the Pi will capture a still image and send notifications to the phone immediately. At the same time, Pi keeps recording the moment for a few more seconds. After that amount of time, if movement is still there, Pi re-captures a new image and sends a new notification. Until there is no more motion, the recorded videos will be pushed to mobile to confirm the motion has ended. The system goes into motion scanning state. The program loops again and again as in this flowchart.
For more detail: Camera Alert Application with Raspberry Pi 3, iOS/Android