Recent release of Raspberry Pi Zero W (W stands for Wireless) motivated me to start another Pi-based project. This time we’re gonna make a fully featured video monitoring system.
Make yourself a coffee, grab a sandwich and hop on, this is gonna be fun!
The goal for this project is to build a fully featured video monitoring system fulfilling the following requirements:
- allows accessing multiple cameras at once and can be easily extended with more of them in the future
- can be accessed from anywhere over the Internet without the need to have an external IP for the cameras
- allows adjusting camera image settings remotely
- allows hooking up and controlling a simple camera pan/tilt head like this one
- does and stores timelapses
- can detect movement and notify about it
- can be accessed and easily controlled using mobiles
The final product will consist of two modules:
- camera client module – installed on Raspberry Pi connects to the central monitoring server giving it the control to take pictures and do other stuff
- monitoring server – gives access to all connected cameras through a control panel web page, can be easily deployed to Heroku or Open Shift or any other server (needs an external IP in this case)
For this project I’m gonna build two cameras based on the following components:
Camera 1, with pan and tilt
- Raspberry Pi 2 model B
- Raspberry Pi Camera v2
- Raspberry Pi 2 case
- SD card
- two 9 gram micro servos
- pan/tilt head
- 5v 2.1A micro USB adapter
- USB WiFi dongle (since Pi 2B doesn’t have WiFi on board)
Camera 2, no pan/tilt
- Raspberry Pi Zero W
- Raspberry Pi Camera v1
- Raspberry Pi Zero case
- Raspberry Pi Zero camera cable – an additonal camera cable is required, as the connector on Pi Zero board is smaller than the one on cambera and the standard cable won’t fit
- SD card
- 5v 2A micro USB adapter
For the installation process and initial setup we’ll need a couple more things:
- HDMI cable and monitor (doh!)
- USB keyboard
- SD card reader
- HDMI to micro HDMI adapter
- USB OTG cable (for Pi Zero setup)
We’ll be using Raspbian Jessie Lite as our OS of choice as we don’t need the desktop support for this project. If you don’t know how to flash it to your SD card, have a look at this short installation guide. Once flashed, we can move to the initial setup.
After plugging everything in and launching your Raspberry Pi, once loaded, the system will ask you to log in. The default credentials are:
Now that we’re logged in, let’s start with some initial configuration. First, we need to change the default password, enable camera and allow SSH access to our device. All of that can be configured using the
raspi-config command. When executed, it will open a nice, visual software configuration tool, which makes the setup incredibly easy.
$ sudo raspi-config
To setup your device, simply follow the on-screen messages, SSH and camera enable/disable options can be found in the “Interfacing Options” section. Once you’re done, click on the finish button and restart your Pi to make sure all the changes got applied.
Now we need to configure the network in order to access to the Internet and download additional packages. Assuming we’ll be using WiFi connection, please follow this detailed article explaining how to set it up using command line.
To check what’s your Pi’s IP address, run:
$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:13:ef:40:00:f1
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: 2a02:c7f:c62d:f300:52ee:a7c7:f760:2478/64 Scope:Global
inet6 addr: fe80::213:efff:fe40:f1/64 Scope:Link
inet6 addr: fd6a:6e51:d18:0:213:efff:fe40:f1/64 Scope:Global
inet6 addr: fd6a:6e51:d18:0:cac5:59fb:9633:64e0/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:148341 errors:0 dropped:5008 overruns:0 frame:0
TX packets:186850 errors:0 dropped:1 overruns:0 carrier:0
RX bytes:94784756 (90.3 MiB) TX bytes:269166578 (256.6 MiB)
Your IP address is represented as
inet addr value, 192.168.0.10 in my case. Write it down somewhere as we’ll need that in a minute.
Once that’s done, lets make sure our packages are up to date. First, lets run:
$ sudo apt-get update
This will download and update package lists. Once done, run:
$ sudo apt-get upgrade
and press Enter whenever asked if you want to continue. This command updates installed packages to their latest versions. It may take a couple of minutes to do so.
From now on we won’t be needing the keyboard and monitor connected to our Raspberry Pi anymore as we can connect to it via SSH!
On Unix-based systems, simply run:
$ ssh pi@<your_ip_address>
<your_ip_address> is the one we’ve written down just a minute ago, and type in your “pi” user password.
On Windows, I’d suggest using an SSH client, like Putty to do the same.
Taking the first picture
With the initial setup done, it’s time to take our first picture with Raspberry Pi camera! Raspbian comes with a bunch of tools to control the camera already included, one of them is
raspistill, a command which uses the camera to take a single picture.
$ raspistill -o test.jpg
-o test.jpg parameter tells it where to save the taken picture. To get the full list of available parameters, run
Let’s see if it actually worked:
Boom! There’s our first picture! But, hang on… It’s not really useful if we can’t see it now that we have disconnected the monitor and keyboard. Later on, it will be our system’s responsibility to make those images accessible over the Internet, but for now we can easily download that image using SFTP.
Unix-based system users can also use the
$ sftp pi@<your_ip_address>
sftp> get test.jpg
This will download the
test.jpg file to the current directory:
In this post we’ve learned how to:
- install Raspbian
- configure it using
- connect to Raspberry Pi using SSH
take pictures using
- download files using SFTP
As always, if you think anything in the above post is unclear or deserves more explanation, feel free to leave a comment.
In the next part we’ll start some actual coding and learn how to take pictures using Node.js. Stay tuned!
Part II is out now, go check it out! – Part II Taking and hosting pictures with Node.js