Instructables

Raspberry Pi as low-cost HD surveillance camera

FeaturedContest Winner
Picture of Raspberry Pi as low-cost HD surveillance camera
mounted_sm.jpg
IMG_2125_xsm.jpg
This instructable describes how to build a surveillance cam based on a Raspberry Pi micro-computer which records HD video when something moves in the monitored area. Live picture can be viewed from any web browser, even from your mobile while you're on the road.
What you will get:
  • See live stream in any web browser from anywhere
  • Record any motion into video file
Usually, such a cam will cost you around US$1.000, but with the result from this instructable, you will get such a cam for only about US$120.
 
Remove these adsRemove these ads by Signing Up

Step 1: Background

Picture of Background

Have you ever heard of Raspberry Pi? It's a low-cost micro-computer that is able to run Linux and has endless extension possibilities. It cost only about US$35 and opens up endless possibilities of what you can build with it. The official website can be found at http://www.raspberrypi.org/

Step 2: Hardware components

Picture of Hardware components
rasp_cameramodule.png
raspberry_cam_housing.jpg
raspberry_power_supply.jpg
SD-card.jpg
wifi-usb-stick.jpg

We need some hardware for this project. This is a list of the major things we need:

  • Raspberry Pi Model B: This is the larger model of the Raspberry computer system with 700MHz and 512MB Ram. It supports HD video. You can easily order it from i.e. here. Cost: about US$40. You could also use the Raspberry Pi Model A which is slightly cheaper and consumes less energy. Stefan Knight has written an excellent article on how to run this whole project on a model A.
  • A housing for the camera: you don't need to buy a high-price-housing for your Raspberry. There are loads of very cheap fake security cameras available which perfectly fit our needs here. Search the web for "surveillance camera dummy" and you will find loads of housings for your new camera for only a few dollars. I.e. this one will do the job: http://amzn.to/15XLaAj for only US$9. We have ordered this camera housing for about 20€ in Germany that had enough space for all the components:http://amzn.to/19CTEaN. You can use any camera housing, but only be careful about the size of the housing so that the Rasperry board will fit in there. The dimensions of the Raspberry board are 85.6 x 53.98 x 17 mm (approx 3.37 x 2.13 x 0.67 in).
  • Power supply: The Raspberry computer does not come with any power supply, you have to get one on our own. Any power supply with a micro-USB plug can do the job as long as it supplies at least 1A of power. We have ordered such a power supply which already has a micro-USB plug for about US$10
  • SD card: as the Raspberry Pi does not have any storage on board, you need to add some so that you can install and run the operating system for this device. Any SD or microSDHC should do the job, but we recommend using a Class 10 SD card. It's only around US$7
     
  • To connect this cam to your network, you also need some kind of network connection. One possibility is to use a LAN connection, but you would need to put LAN cable to the point where you want to mount the camera. A better alternative is such a WiFi USB adapter for only about US$10
That's all: for about US$120 we have all the hardware we need to build this HD surveillance cam.

Step 3: Install Raspbian

At first, you should install the OS and software to the Raspberry Pi before mounting it all together. An OS is the basic operating system software that tells the Raspberry hardware what to do. Linux is perfect for this. We have chosen Raspbian, as it's one of the most advanced OS for the Raspberry with loads of help and tutorials on the internet.
You need to prepare the SD card to be able to run Raspbian on the Raspberry: this excellent tutorial from Adafruit will explain the necessary steps.
Now temporarily connect your Raspberry Pi board to LAN cable, a monitor (HDMI TV works out of the box, but a HDMI-to-DVI cable like this will do the job as well) and a USB keyboard for the basic setup.
Insert the prepared SD card with the Raspbian installer on it and attach the power supply.
The Raspberry should boot up and guide you through the setup process as explained in this Adafruit tutorial. After this, you should have a basic Raspbian OS running.
Be sure to enable SSH in Raspbian so that you are able to control the Raspberry device also when there is no monitor and keyboard attached. And you should also enable the camera from the Raspbian setup menu so that we can use it for motion detection.
Now make sure your RPI is up to date:

sudo apt-get install rpi-update
sudo rpi-update

And also update all packages:

sudo apt-get update
sudo apt-get upgrade

Step 4: Connect via SSH

Picture of Connect via SSH

Now that the basic setup is done, you should connect to your Raspberry device from your computer. You can connect to Linux console from any computer in your local network and control it like you where sitting directly in front of it. This is very important as once mounted far away from your desktop, you need to be able to make updates and change the configuration of this camera any time later without the need to detaching it from the wall and bringing it back to your desk.

Remember that this cam is not just a dump cam device but a very powerful computer with Linux OS running on it. It's not limited to what we explain in this article now; it will follow any development in software so that you will be able to install updated software and more modules any time later.

First, you need a software to connect to the Linux console on the Raspberry. For Windows, you will need the extra (free) software PuTTY. Download it from the PuTTY website, install it and connect to your Raspberry Pi device:

From now on, you don't need any monitor and keyboard attached to the Raspberry anymore.

Step 5: Enable WiFi

If you want to run this camera with a WiFi USB dongle (like we've suggested in step 2), you will need to do some quick additional steps to make WiFi work on the Raspberry:
From the console (PuTTY window), edit the network properties of the Raspberry:
sudo nano /etc/network/interfaces 
Now add these lines at the end of the file (or change existing lines to match these):
allow-hotplug wlan0 
iface wlan0 inet dhcp 
wpa-ssid "YOUR NETWORK SSID"
wpa-psk "WIFI PASSWORD"
(Fill in the SSID and password for your WiFi network)
Reboot the Raspberry with this command and see if it correctly connects to your WiFi network:
sudo reboot  

Step 6: Put the hardware together

Picture of Put the hardware together
mounted_sm.jpg
IMG_2121_sm.jpg
Now it's time to assemble all the hardware components together into the housing. Depending on the housing, this should not be a too complicated job. Be sure to mount the Raspberry board safely so that it doesn't tumble around in the housing.
As our housing had a very large glass window at the front, we have closed it with a black paper with a hole in it. This has the advantage that the "tech" of the camera is not visible anymore. If you like the camera recording led to be visible, don't cover it. Whenever the camera is detecting any motion or is recording, the led light will glow in a very bright red.
You can also turn off the camera red LED by adding this line to /boot/config.txt:

disable_camera_led=1



Step 7: Installing the motion detection software

A very good (and free open-source) motion detection/surveillance software with many configuration options is motion.
We now need to install it using the command line (log in to your raspberry as user "pi"):
sudo apt-get install motion 
Some packages will be installed in the installation process; just type "y" to proceed with the installation.
As the current version of motion does not (yet) support the Raspberry camera module, we need to download and install a special build with support for this camera module.
cd /tmp 
sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz  
And now you need to unpack the downloaded file to the /tmp directory:
tar zxvf motion-mmal.tar.gz  
After this unzipping, you now need to update your installed motion with the downloaded build:
sudo mv motion /usr/bin/motion
sudo mv motion-mmalcam.conf /etc/motion.conf  
You also need to enable the motion daemon so that motion will always run:
sudo nano /etc/default/motion
and change the line to:
start_motion_daemon=yes
We're pretty sure that the official build of motion will shortly also support the Raspberry camera module as well.
A very important command to edit the motion configuration file is
sudo nano /etc/motion.conf  
Note: in the standard motion installation, the motion.conf is in /etc/motion/, but in the special motion-mmal build from dropbox-url (see above) it's in /etc/. If you follow this tutorial with all steps, this is no problem at all.
Be sure to have the file permissions correct: when you install motion via ssh while being logged in as user "pi", you need to make sure to give the user "motion" the permissions to run motion as service after reboot:
sudo chmod 664 /etc/motion.conf
sudo chmod 755 /usr/bin/motion
sudo touch /tmp/motion.log
sudo chmod 775 /tmp/motion.log  
We've made some changes to the motion.conf file to fit our needs. Our current motion.conf file can be downloaded here. Just download, unzip and copy the containing motion.conf to /etc/motion.conf if you would like to use the exact config options we describe below.
Some of the main changes are:
Make sure that motion is always running as a daemon in the background:
daemon on 

We want to store the logfile in /tmp instead (otherwise autostart user won't be able to acces it in /home/pi/ folder):

logfile /tmp/motion.log
As we want to use a high quality surveillance video, we've set the resolution to 1280x720:
width 1280
height 720 
We don't need real-time video, 2 pictures per second are totally ok for our needs:
framerate 2 
This is a very handy feature of the motion software: record some (2 in our configuration) frames before and after the motion in the image was detected:
pre_capture 2
post_capture 2 
We don't want endless movies. Instead, we want to have max. 10 minutes slices of the motion videos. This config option was renamed from max_movie_time to max_mpeg_time in motion. If you use the motion-mmal build, this one will work. If you get an error 'Unknown config option "max_mpeg_time"' either change this one to max_movie_time or make sure to really use the motion-mmal build as shown above.
max_mpeg_time 600 
As some media players like VLC are unable to play the recorded movies, we've changed the codec to msmpeg4. Then, the movies play correctly in all players:
ffmpeg_video_codec msmpeg4  
Enable access to the live stream from anywhere. Otherwise only localhost (= the Raspberry device) would be allowed to access the live stream:
stream_localhost off 
If you want to protect the live stream with a username and password, you should enable this:
stream_auth_method 2  
stream_authentication SOMEUSERNAME:SOMEPASSWORD 
All configuration parameters are explained in detail in the motion config documentation.
After your changes to the motion.conf, reboot the Raspberry:
sudo reboot  
After the reboot, the red light of the camera module should be turned on, which shows that motion currently is using the camera to detect any movement.

Step 8: Save videos on Windows shared folder

As the SD card of the Raspberry Pi is a pretty limited resource, we've decided to let the Raspberry cam store the videos on one of our Windows Servers. This is pretty easy:
First share a folder from some Windows machine. Just follow some guides on the internet if you've never shared a folder from a Windows machine before.
Then open the fstab configuration on your Raspberry from a PuTTY console or directly from the device:
sudo nano /etc/fstab  
Now add an extra line with the configuration of your Windows network shared folder:
//YOURSERVERNAME/YOURSHAREDFOLDERNAME /mnt/camshare cifs username=YOURSHAREDFOLDERUSERNAME,password=YOURSHAREDFOLDERPASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0 
Be sure that the user has the correct permissions to save files to that shared folder.
After a reboot, the Raspberry should have an extra folder /mnt/camshare mounted to the Windows shared folder. You should now set in your motion.conf:
target_dir /mnt/camshare 
so that motion saves all movies to the shared folder on the Windows machine.


Step 9: Fix motion autostart

Picture of Fix motion autostart
We had some trouble that motion was not automatically started on a reboot of the Raspberry. We've found out that this was because the mounted folder of the Windows machine was not yet ready when motion tried to access it.
A very quick fix solved our problem:
Just edit the motion file with
sudo nano /etc/init.d/motion 
and add the line
sleep 30 
to the start-sequence.
Our changed /etc/init.d/motion script can be downloaded from here.

Step 10: Mounting the camera

Picture of Mounting the camera
After all these steps, you can finally mount the surveillance camera to the destination point.
Some helpful hints:
  • Be sure to place the power supply in a dry and safe place
  • Keep an eye on the WiFi signal: if you mount the camera out of range of the WiFi, it won't be able to send any live video nor save any motion videos

Step 11: Accessing the live stream

Now you can access the live stream from the camera from any browser via the url http://IPADDRESSOFRASPBERRY:8080
Where 8080 is the port that we've configured for our stream in the motion.conf file. See your own configuration setting "stream_port" in motion.conf for the port.
We've found out that Google Chrome 30 (not even on iOS) wasn't able to play this stream directly due to a bug in the underlying Chromium project.
A workaround for this is to create a simple html file that contains one large image with the stream-url of the camera. See the file cam.html from raspberry_surveillance_cam_scavix.zip. This way, Chrome can show the live stream as well. Let's hope that Chrome will fix this issue in their browser.
But other browsers like FireFox, Safari and even VLC media player was able to show the live stream of the camera.
We were not able to make the live stream work in Internet Explorer as it doesn't support Motion JPEG. Kenneth Lavrsen (the maker of motion) has described workaround for live stream in Internet Explorer here.

Step 12: Access live stream from anywhere

Picture of Access live stream from anywhere
live_stream_mobile.jpg

To make the live stream accessible from anywhere, you will need to enable some kind of dynamic domain services to your local network. This will enable you to always be able to connect to your local IP address from the outside even if your local IP address changes (over here in Germany, every private DSL ip address changes every 24 hours).
Such a (free) service enables you to access your Raspberry from anywhere even if your ip address changes. A very good service we're using for some years now is dyn.com. They have some free services and are integrated in many routers.
Once you have set up the dynamic ip url, you can access the camera stream from anywhere in your browser (i.e. http://YOURDYNAMICDOMAIN:8080).
And this also works from the browser on your mobile device.

Step 13: Next steps

There are a thousand things you can do with such a surveillance cam basic setup now. How about sending Growl notifications when some motion was detected? This guide explains how to add this functionality easily.

Or you could easily add a temperature-sensor to the cam. It's only a few bucks and can be integrated very easily.
We're currently working on integrating the live stream into MediaPortal server so that we can switch to a TV channel to see the live stream from the cam in our office.

If you want extra security, you could also add a battery pack to the camera. Be sure to buy one that is able to charge simultaneously while powering the Raspberry. This would enable you to detect if some bad guy cuts the power strips of your camera and send some alert messages to you (i.e. SMS or email) including the video of the disturber.

What are you going to add? Let us know!

1-40 of 169Next »
cmcdowell729 days ago

For a $120 that's not actually a good deal considering that PTZ cameras
nowadays are expensive for a common folk like me. Anyway, I don't know much
about installations and anything technical is there any available Raspberry Pi
cctv camera that's a plug and play?

scavix (author)  cmcdowell729 days ago
Raspberry Pi is about making things yourself. The DIY is big part of the fun. I don't know of any prebuilt cctv cameras with Raspberry inside.
Wingspinner1 month ago

A few comments....

First, thank you scavix for putting up this very comprehensive tutorial. There are so many that people put up that never worked in the first place but your's actually does and it's well written. Thanks, nice job!

Second, I have a few suggestions for those of you having problems getting it going:

1. Start from an absolutely fresh install of Raspian. Don't re-use one you've been playing with. You'll avoid a lot of headaches if you start fresh so you are working from exactly the same starting point as scavix

2. Use a class 10 SD card. Despite the fact that Raspian can supposedly work with slower cards I've generally found that the slower the card the flakier things get.

3. My primary usage is as a security cam and I want the RPi to behave much like my Vivotek IP3130W IP cam. For that purpose I don't need large, super high-res videos or stills. I found more robust results by using a smaller frame size. There are several reasons for this but mostly it has to do with RPI processor performance and data bandwidth. The motion detection, the jpeg encoding, and network transfer are all done with the processor according to dozencrows, the author of the RPI patches to the motion package and this . The following resolutions are known to work without problems according to him:

352 x 288
512 x 288
640 x 480
768 x 432
768 x 576
1024 x 576

He says others may work but haven't been thoroughly tested. I've got three of these running at 640x480 at 5 FPS for weeks now with no lockups or reboots.

4. Related to bandwidth issue, if you point the output files to a RAM based file system response time and reliability go way up in my experience. Of course, you'll be limited as to how much video you can store but if you are using it for a security cam you don't need to have many huge, high-res captures just "the ones you need" (I'll address that next). I didn't want to make it complicated so I simply mounted /tmp on the tmpfs file system (ramdisk based). To do that add the line "RAMTMP=yes" in the file /etc/default/tmpfs. Use "sudo nano /etc/default/tmpfs" to edit the file. Then, in the "/etc/motion.config" file set "target_dir=/tmp" and "logfile=/tmp". Be aware that any files written to a ram based filesystem are lost if you power down or reboot so this may not be right for you.

5. There are a number of configuration variables that can be optimized for your particular needs. I want to minimize storage and bandwidth requirements but have nice looking real-time streaming so I've set the following:

framerate 2

# despeckle_filter EedDl

minimum_motion_frames 5

event_gap 10

max_mpeg_time 10

ffmpeg_variable_bitrate 5

stream_quality 75

stream_maxrate 5

All others set to either default values or what scavix has specified.

5. Lastly, I installed watchdog timer support which will automatically reboot the RPi if the processor hangs or if the file systems get full (this can be configured).

I hope these pointers can help. Good luck!

@Wingspinner, I totally agree with your comments about scavix's comprehensive tutorial. But I'm disappointed that the RPi cam module cannot use the it's full potential: 1080p with 30 fps. That's why I'm now using RPi Cam Web Interface: http://www.raspberrypi.org/forums/viewtopic.php?t=...

Oh, one more thing. By the time I factored in all the costs of putting an RPI based IP cam together it really wasn't much of a savings over a good quality ready-made IP came. I have a couple of the Vivotek IP8130W HD cameras and I'm very pleased with their performance and reliability. Not only are they HD but they are very flexible in terms of setup and have excellent low-light and no-light performance. Best of all they can be had for around $170 so and RPi based camera with case, power supply, etc. etc is only $40-$50 cheaper. A lot of fun though!

nikkala1 month ago

This has been a great tutorial! But I have a one problem: As soon as there is any motion in front of my cam, the stream cuts off. How could I fix this? The red led of the cam is always on, and when there is any motion led goes off and stream wont work. Oh yes, and my pi is not saving any of my videos to my shared folder.

scavix (author)  nikkala1 month ago

In your motion.conf, set the log_level to 9. Then reboot your pi and see what the motion.log says.

This is the general procedure for any kind of problems. As motion will tell you in it's log file what it doesn't like.

nikkala scavix1 month ago

Thanks! It seems like I have messed up somewhere while creating a shared folder. After doing all the steps there is still no any folders like /mnt/camshare and the pi keeps saving pictures in the pi itself. After all I think my problem looks like to be the same as the guy below, Nikhil. So I have to keep on working on this...

/mnt/camshare folder is not created after performing all the steps,so m unable to record videos automatically to my shared folder .
Give me some advice, may be I have gone wrong somewhere
In step 7 after doing all steps when I reboot the system , the red light of the camera is not on i.e. It is still off.
So please help me out.
StudioDubio2 months ago

I ran into another issue. After succesfully installing motion and get the camera working I changed the shared folder to my NAS ip address. After sudo reboot the camera doesn't start (no led and no stream possible in VLC). Please help!

ryanlogan2 months ago

Well, I must have messed something up somewhere...I don't have an /etc/init.d/motion file

I assume that is created with one of the installers?

I had the same problem. Installing raspbian and start over again did the trick

I meant to come back yesterday and post after I got it working but I went back and ran trough the installs and did updates again and that seems to have done it. Thanks...
Caldes made it!3 months ago

Hi.

Great tutorial!

I followed all steps and it worked for me. It shows up in Firefox perfectly and... I actually had no problem in registering the stream to the Surveillance software on my old Synology DS207+ running DSM 3.1. That's great and fun!

I had two problems at start since I didn't get any recordings on the target_dir "/mnt/camshare/Cam1" (permission set to 755) and the live stream got unavailable after a little time of use. Often just after a few minutes. Both problems where solved after setting the rights of the target_dir to 777. I guess Linux people will hang me for this and I should probably look into giving the motion process the necessary write rights instead of setting it to 777. But for now while testing and debugging it fits me well.

A fun thing to do now would be to motorize the camera and make it rotate through the Pi ;-) I see that the motion.cfg file opens for this functionality.

/Krissi

Temp.png

@Caldes, how did you managed to register the stream in Synology? What path do I need to use? I own a DS212 with DSM 5.0 but can't get it running.

CeesA Caldes2 months ago
(removed by author or community request)
CeesA CeesA2 months ago

Sorry, accidentally deleted my questions, underneath answered by Clades. Where for my thanks. I think everybody can guess my questions.

Got my camera working. Thanx. The chmod did the thing.

will now try your tips on using the surveillance software of the Synology.

CeesA CeesA2 months ago

Surveillance is working like a charm. Next item would be the buggy recording. Has anybody tackled this? Changed my resolution back to 1024 but this did not solve the problem. Perhaps i should tell motion not to record any mpeg or jpeg. The Synology is doing this for me. The cpu of the RBPi should be less occupied when doing this. Anybody any suggestions?

C.

Caldes CeesA2 months ago

Hi CeesA

He, he... glad that it worked for you. What do you mean by buggy recording. Is it related to the frames pr. second that you specify on the motion.conf?

I have a question now that you talk about resolutions. Have you tried to set the camera parameters to 1920x1080?

I ask that since I experienced that the recording worked fine with the resolution set to 1280x720 but failed with the settings set to 1920x1080. I found that strange since the camera should support it.

Cheers

CeesA Caldes2 months ago

Hi Caldes,

with the buggy recording i mean also the stream received on my DS213+. I think this is because of the the double recording (both RBPi through mount, and via SS6). I only want to use SS6, so the RBPi motion recordings I'd like to shut down. Found some commands like output_all, output_motion and output_normal but all are not recognized by motion.

All input is welcome

C.

Caldes CeesA2 months ago
Hi CeesA.

I used the same motion.conf as scavix. In that file the Target Base Directory is set by the line:
target_dir /mnt/camshare/Cam1

That is the local directory that I needed to change the permissions in by using the command:
sudo chmod 777 /mnt/camshare/Cam1

.oO(my guess is that 775 will also work)


Regarding the Synology I didn't do anything particular to make it work. Using scavix's guide I was able to live stream the Raspberry Pi's camera to a browser (i.e. http://192.168.1.121:8080/). Once that worked I just told Synology's surveillance software to use that URL. See the attached image to see the settings on my Surveillance Station 5 (SS5 in the next).

When using SS5 I don't need to mount anything for the RBP on my Synology since SS5 does that for me by creating an archive that I can manage from within the configuration windows (see attached image). So, it was pretty much "Plug & Play" for me.

NOTE!
I am aware that this solution stores the captured images/movies twice since it stores it on the local memory card (/mnt/camshare/Cam1) and on the Synology. That is fine while playing with it. If used for "real survillance" I would stop storing anything locally and just keep having my Synology grab the stream from the URL.

Hope this helps.

Regards
Temp.pngTemp2.png
Caldes Caldes3 months ago

I think I should comment that I don't agree that this is a replacement for a camera in the $1.000 range. This solution doesn't give you both day and night vision and doesn't include IR lights needed if you install/buy the night RPi camera.

I can actually Google an IP-camera that does all that for less than $150. Nevertheless it is a lot of fun to make this solution work and that is just what the Raspberry Pi is all about.

The attached image is a shot with the night lens on... the grass is green ;-)
The previous image was taken at about 5 am and I had only a television to test on. The main purpose of the image was to show that it works on Synology surveillance software.

Temp.png
alilike162 months ago

Nice

gangrel1442 months ago

I read over there this:

We don't need real-time video, 2 pictures per second are totally ok for our needs

But can i get real-time video? or What is the maximum framerate for the raspberry pi?

rfahad12 months ago

When I try to run motion I get this

[-1242389664] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion.conf

[-1242389664] [NTC] [ALL] motion_startup: Motion mmaltest Started

[-1242389664] [ERR] [ALL] myfopen: Error opening file /tmp/motion.log with mode a:

Message from syslogd@raspberrypi at Apr 28 03:37:58 ...

motion: [-1242389664] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /tmp/motion.log:

[-1242389664] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /tmp/motion.log:

rfahad12 months ago

Thank you for this clear tutorial but I'm facing a problem

I followed all the steps but I cannot view the live stream I tried to view it on Safari it says cannot connect to server. I have tried VLC as well and I get the same message.

I checked the camera module and it's working fine (I am using the NoIR version)

I have noticed that when I boot the Raspberry Pi I get this message […] Mounting local filesystems..mount: mount point 0 does not exist

failed

Will someone please help me it's becoming really frustrating

chiruru3 months ago

solved... Thanks,

I can store video into external USB memory...

But Streaming Video is too slow and CPU is Full busy...So CPU of Rpi is very hot.

Any idea?

l33n0x chiruru2 months ago

Unfortunately you can't ask more to the Rpi. The image analysing is a huge job ! You can try with a lower resolution.

chiruru3 months ago

USB memory include microSD card.

chiruru3 months ago

I want to use USB memory on Rpi instead of Windows Directory.

So I mounted USB memory at /home/pi/microSD.

And Then, What can i do?

Please commant me. I wan to store motion movie into the USB(internal microSD).

Thanks,

pi@raspberrypi ~ $ sudo fdisk -l

Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes
4 heads, 16 sectors/track, 242560 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ca5f0

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 2822265 1407037 e W95 FAT16 (LBA)
/dev/mmcblk0p2 2826240 15458303 6316032 85 Linux extended
/dev/mmcblk0p3 15458304 15523839 32768 83 Linux
/dev/mmcblk0p5 2834432 2957311 61440 c W95 FAT32 (LBA)
/dev/mmcblk0p6 2965504 15458303 6246400 83 Linux

Disk /dev/sda: 7948 MB, 7948206080 bytes
255 heads, 63 sectors/track, 966 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 8192 15518789 7755299 b W95 FAT32

pi@raspberrypi ~ $ cat /etc/passwd | grep pi
pi:x:1000:1000:,,,:/home/pi:/bin/bash

pi@raspberrypi ~ $ mkdir microSD

pi@raspberrypi ~ $ sudo mount /dev/sda1 /home/pi/microSD

pi@raspberrypi ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 5.8G 2.5G 3.1G 45% /
/dev/root 5.8G 2.5G 3.1G 45% /
devtmpfs 180M 0 180M 0% /dev
tmpfs 38M 272K 38M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 75M 0 75M 0% /run/shm
/dev/mmcblk0p5 60M 19M 41M 32% /boot
/dev/sda1 7.4G 96K 7.4G 1% /home/pi/microSD

pi@raspberrypi ~ $ sudo nano /etc/fstab
GNU nano 2.2.6 File: /etc/fstab Modified

proc /proc proc defaults 0 0
/dev/mmcblk0p5 /boot vfat defaults 0 2
/dev/mmcblk0p6 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, so no using swapon|off from here on, use $
/deb/sda1 /home/pi/usb vfat gid=1000, uid=1000 0 2

pi@raspberrypi ~ $ sudo shutdown -r now

pi@raspberrypi ~ $ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 5.8G 2.5G 3.1G 45% /
/dev/root 5.8G 2.5G 3.1G 45% /
devtmpfs 180M 0 180M 0% /dev
tmpfs 38M 276K 38M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 75M 0 75M 0% /run/shm
/dev/mmcblk0p5 60M 19M 41M 32% /boot
/dev/mmcblk0p3 27M 422K 25M 2% /media/SETTINGS
/dev/sda1 7.4G 96K 7.4G 1% /media/3ABC-62D9

And then, What can i do?

jeffgb3 months ago

I followed these instructions to the letter and never got it to do a thing. I know the hardware is working since the camera will respond to raspvid commands. Instead of using my NAS drive, I have the raspberry storing on a usb drive, but I gave it the 30 second delay anyway. I even gave everything 777 permissions.

I was most interested in using this for a live feed. I have a dyndns account and that works fine for everything else I do with the pi. Forwarded 8080 and 8081 to the pi ip address on the router but those ports never show as open, leading me to believe the service never started. If I just type 'motion' in the terminal, it tells me that it can't open the log file with mode a.

starting with 'sudo motion', seems to get everything running, but no feed.

Also, even if you do use the downloaded motion-mmal build, there is "max_mpeg_time"' in there. Had to use 'movie'

l33n0x3 months ago

Hi everyone,

I made it and worked like a charm with the Synology Surveillance Station.
Unfortunately the framerate is really low (like 2 fps+) even in tuning the config file... I see the motion process at 97% and I conclude the processor limit is reached...

Any idea if we can disable the motion detection to keep only the stream at better framerate ?

Other point, I've updated my Pi to last firmware and the image from motion is in very low resolution... MMAL need to be updated I think ?

Thanks for the good instructions ;-)

pengocha3 months ago
Definitly going to try this out. I'm wondering, would it be possible to add a smoke alarm together with this project. An alarm would be triggerd if a burglar is in your house and also if there's a fire. That seems a very usefull feature to me.
raka193 months ago

I am building a second camera for my home. The first one was resounding success! Thanks to this instructible. I replicated all the steps correctly for my second camera (as far as I can tell) but for some reason I cannot view the stream or capture videos. I changed the stream_port on motion conf to something other than 8080. I chose 9080 arbitrarily. 8080 is being used by my first camera. I do not see the stream or capture videos. I even changed my first camera stream_port to 7080 (arbitrary again) and changed the second camera I am working on to 8080. The first one works like a charm even with the changed stream_port but the one I am building one does not work. Is there a way to check if the camera module itself is working correctly. Since I installed motion s/w , the default camera application in Rasbian does not work any more on either camera wit the following commands.

raspistill -o image.jpg

raspivid -o video.h264

Is there any other quick way to check if the camera is working correctly? Basically I need to segment out the issue but I do not know what is causing the issue. Otherwise I will have restart from scratch. Any tips will be appreciated.

raka19 raka193 months ago

Quick update. I removed motion software to check of the default camera application was working correctly. It gave me an error. Based on that I figured that the camera was fried, possibly by accidentally dropping it or static from me. Ordered a new camera module and resolved the issue.

dailodai783 months ago

GREAT instructable. have you considered adding high powered LED lights into that housing?

battleangel3 months ago

I just wanted to say I am very excited about this project. One lingering question though: How do you secure your electronics against moisture / humidity? A completely air-tight camera housing (difficult)? Or small drainage holes in the bottom? Will the power consumption of the RPi (3.5W + voltage conversion via PoE ~ 6W) work with or against me? I.e. keep the casing warm and dry or in fact force moisture to condensate inside the case? Would stuffing the case full of silica gel help or would it need to be replaced too often to be of any practical use? Or would I have to waste more watts on a heater and a fan inside the housing? Btw, I got one of the housings from AliExpress, tried to keep the size down and ended up with a "short" model of only about 20-23cm so the air volume inside the case should be limited. I will in time add more hardware to the setup, like a wireless transceiver and possibly a Razzberry so protecting the hardware against corrosion is of great importance. Too bad I can't just put the whole darn thing in silicone or hot glue or something. Ideas?

eddie87 months ago
This is really impressive, but is it possible to make one that is not so bulky? You know a smaller verson that may not be visible to others, such as a smoke detector type that will not bring attention to itself? If so please let us know what modifications -- if any, we need do. Thamk U,
mfrontuto eddie83 months ago

eddie8, you can do that, but you would have to put the bulk of the items, the Pi, and components in another shell and get a camera with a long cable or buy an extension cable for it to house just the camera in a tiny unit like a smoke detector or even a dummy light bulb, or in an actual smoke detector. So you could house the Pi right above the smoke detector on the other side of the drywall run the extension cable for the camera into the smoke detector and now you have both a working smoke detector and security camera, just drill a hole in the smoke detector for the cameras lens to be able to look out of

1-40 of 169Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!