raspberry pi

16
Computer College LECTURE MODULE Microelectronics Effectivity: 2014 - 2015 Document Reference: Revision No: 1 IssueNo: 1 DateIssued: May 18, TITLE CCTV Camera Using Raspberry Pi OBJECTIVES To design and construct a CCTV Camera using Raspberry Pi that can access through the Internet browser. INTRODUCTION The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games. Prepared by: Section AE Reviewed by: Engr. Michelle P. Pullon Approved by: 1

Upload: aprilynromero

Post on 17-Sep-2015

225 views

Category:

Documents


5 download

DESCRIPTION

nyaks

TRANSCRIPT

Computer CollegeLECTURE MODULE

Microelectronics

Effectivity:2014 - 2015Document Reference: Raspberrypi.orgRevision No: 1IssueNo: 1DateIssued: May 18, 2015

Title

CCTV Camera Using Raspberry Pi

Objectives

To design and construct a CCTV Camera using Raspberry Pi that can access through the Internet browser.

Introduction

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. Its capable of doing everything youd expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games.

Materials Needed

Raspberry Pi SD Card We recommend an 8GB class 4 SD card.

Display and connectivity cables Any HDMI/DVI monitor or TV should work as a display for the Pi. For best results, use one with HDMI input, but other connections are available for older devices. Use a standard Ethernet cable for internet access. Keyboard and mouse Any standard USB keyboard and mouse will work with your Raspberry Pi. Power supply Use a 5V micro USB power supply to power your Raspberry Pi. Be careful that whatever power supply you use outputs at least 5V; insufficient power will cause your Pi to behave in strange ways. Inexpensive webcam Router or a wireless Wi-Fi module

Procedures

1. First, you must download the NOOBS image from theRaspberry Pi website. There are a couple different options for download: NOOBS (offline installer) Torrent Compressed ZIP NOOBS LITE (online installer) Torrent Compressed ZIP The offline installer is significantly larger than the LITE version, but comes with the ability to reinstall the Raspbian operating system without a network connection. This is because the actual OS image is saved onto the SD card when you install NOOBS for the first time. However, over time the OS image that is included in the NOOBS installation may become outdated unless you have a network connection, in which case the newer OS version will be downloaded and installed. NOOBS LITE is significantly smaller in size, but requires a network connection to install the OS images. Both the regular NOOBS and NOOBS LITE installers allow for installing from a network. Once youve downloaded the version of NOOBS you prefer (either the regular version or LITE), then you can simply extract the ZIP file.

2. Formatting Your SD Card Before you can actually place NOOBS onto your SD card, you must format it. Note, formatting the card erasesalldata on it.3. Copying NOOBS Once you have a formatted FAT SD card, you can simply copy the files for NOOBS that you extracted earlier. A simple copy and paste is all that is needed. It might take a while to copy the regular version of NOOBS due to the slow speed of SD cards, but once its done you can eject the card from your computer and insert it into your Raspberry Pi.4. Using NOOBSInstalling an OS Before you plug your Raspberry Pi into the power cable, attach a USB keyboard and mouse so that you can navigate the NOOBS interface. Once you have the keyboard and mouse plugged in, you can turn on the power to your Raspberry Pi and you should be greeted with a screen similar to the following:

This is the operating system installation screen, and allows you to choose one or more OS images to install onto your SD card. Notice the icons on the right hand side those OS images with a picture of an SD card are already included with your NOOBS installation, while those with an Ethernet symbol can be downloaded over a network.Simply check the boxes next to the OS images you wish to install, and hit the install button in the toolbar at the top of the window.5. Boot Selection Once youve installed one or more operating systems with NOOBS, rebooting your Raspberry Pi will result in one of two things happening automatically: If you have a single OS installed, it will boot automatically If you have more than one OS installed, a boot selector will be displayed

To get back to the OS installation screen, simply hold the shift key on your keyboard as you turn on your Raspberry Pi. There are many postson the Internet, demonstratinghow to build a Raspberry Pi-powered camera system. One of the more frequently used off-the-shelf applications for these projectsisMotion. Motion has the abilityto stream images from awebcam and server them from it isbuilt-in web server, with little or no configuration. In addition, Motion is easily configured to work with streaming video applications like the very popularFFmpeg, andsave images to databaseslike mySQL or PostgreSQL. Motion can also execute external scripts such as python or shell.6. Firmware UpdateBefore installing Motion, the researchers recommend ensuring your Raspberry Pi is up-to-date with the latest software and firmware. Updating firmware is not necessary. The researchers updated the firmware on the Raspberry Pi. It fixed the problem. Installing firmware can sound a bitintimidating. However,Liam McLoughlin (hexxeh) has made the process easy withrpi-update.7. Software UpdateThe researchers also update your Raspberry Pis existingsoftware. To update the Raspberry Pis software, execute the following apt-get commands:1sudo apt-get update && sudo apt-get upgrade

If you dont do this on a regular basis, asrecommended, these could take up to several minutes. Watch for errors. If there are any errors, try to run the commandagain. Sometimes the Raspberry Pi cannot connect to all code repositoriesfor updates.8. Installing MotionOnce the updates are complete, install Motion by issuing the following command:1sudo apt-get install motion

9. Enabling MotionAs the installation completes, you should see a warning in the command shell about Motion being disabled by default.1234567...Adding user `motion' to group `video' ...Adding user motion to group videoDone.[warn] Not starting motion daemon, disabled via /etc/default/motion ... (warning).Setting up ffmpeg (6:0.8.4-1) ...pi@garyrasppi ~ $

To enable Motion (the motion daemon), we need to edit the/etc/default/motionfile.1sudo nano /etc/default/motion

Change the start_motion_daemon parameter to yes.

10. Configuring MotionMotion is easy to customize with loadsof parameters you can tweak based on your needs. Motion has no GUI. All configurations are all done through Motions configuration file (/etc/motion/motion.conf). Before editing the configuration file, we need to change the permissions on it, so Motion can get access to it. While we are at it, we will also change permissions on the folder where Motion stores captured images.12sudo chmod -R 777 /etc/motion/motion.confsudo chmod -R 777 /tmp/motion

After changing the permissions, toconfigure Motion, open the Motions configuration file in a text editor, as root(sudo). The configuration file can be opened in Nano with the following command:1sudo nano /etc/motion/motion.conf

Motions configuration file is lengthy. However, it is broken down into logical sections, making finding the setting you are looking for, easy. First, we need to change the Live Webcam Server section of configuration. Below are the default settings:

The first thing you will want to change is Motions default setting that restricts image streaming to localhost, only (webcam_localhost on). This means you can only view images in a web browser on the Raspberry Pi, not remotely over your network. Change that line of code to read webcam_localhost off. The next setting we recommend changing for security purposes is the default port Motions web server uses to stream images, 8081. Security through obscurity is better than no security at all. Changeport 8081 to a differentarbitraryport, for example, 6789 (webcam_port 6789).Just make sure you dont picka portalready in use by another service or application. Having made this change, ifyour Raspberry Pis localIP address is192.168.1.9, images from thewebcam should be accessible at 192.168.1.9:6789. The other two settings in this section you can play with are the webcam quality and maximum frame-rate. You will have to adjust this based on yournetworkspeed and the processing power of your Raspberry Pi. The default settings are a good place to start. Speaking of quality, the other two settings you may want to change are the width and height of the image being captured by Motion. TheCapture device options section is where we change these settings. As the configurationscomments suggest, these settings are dependent on your camera. Check the cameras available image sizes; you will need to use one of those size combinations. I have mine set to an average size of 352 x 288. This is a good size for those of us with a slower network, or when streaming video over the Internet to mobile web browser. Conversely, a larger image is better for viewing overyour local network. Image size, like compression quality, and frame-rate are dependent on processing power of your Raspberry Pi and its OS (Raspbian, Debian, Arch, etc.). You may need to play with these settings to get the desired results.

12345# Image width (pixels). Valid range: Camera dependent, default: 352width 352# Image height (pixels). Valid range: Camera dependent, default: 288height 288

Its important to remember, each time you make changes to Motions configuration file, you must restart Motion, using the following command.1sudo /etc/init.d/motion restart

11. Viewing the WebcamTo view the webcams output from another device on your local network, point your web browser to the IP address of your Raspberry Pi, and add the port you assigned in Motions configuration file. Motion may take up to 15-20 seconds to start responding in the browser. If it takes longer, you probably have your image size, frame-rate, and compression settings to high for your Raspberry Pi.12. Over the InternetEnablingyour webcams output over the Internet isrelatively easy with the average home router and Internet service provider.

Prepared by:

Section AEReviewed by:

Engr. Michelle P. PullonApproved by:

12