DIY video monitoring system, Raspberry Pi

DIY video monitoring system – Part I – Overview, setup and the first picture

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!

Introduction

Over the course of the next few weeks, we’re gonna learn a couple of things about Raspberry Pi, Node.js, WebSocket and even a bit of Vue.js!

This project is designed for people with some basic knowledge of Unix-based systems, JavaScript and computer networking, but my goal is to make this as easy to understand as I can, so that even a complete newbie will be able to do this on their own just following the steps I listed here.

The system

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)

Hardware

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 with Pi Camera v2
Raspberry Pi 2 model B with Raspberry Pi Camera v2
  • 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)
Pan/tilt head
Pan/tilt head with wiring already prepared to connect to GPIO

Camera 2, no pan/tilt

Raspberry Pi Zero W
Raspberry Pi Zero W
  • 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

Other stuff

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)

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:

  • login: pi
  • password: rasbperry

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.

raspi-config
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:

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:

This will download and update package lists. Once done, run:

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:

where, <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.

The -o test.jpg parameter tells it where to save the taken picture. To get the full list of available parameters, run raspistill --help.

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.

Depending on the operating system we’re using, there are different ways of connecting using SFTP. The easiest one is using a GUI (S)FTP client like Filezilla or WinSCP.

Unix-based system users can also use the sftp command:

This will download the test.jpg file to the current directory:

Apple
Our first picture taken with Pi Camera

Summary

In this post we’ve learned how to:

  • install Raspbian
  • configure it using raspi-config
  • connect to Raspberry Pi using SSH
  • take pictures using raspistill
  • 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

by Greg

No Comments »

Leave a Reply

Your email address will not be published. Required fields are marked *