Introduction: Raspberry Pi Security Cam


Here I will be working an a Raspberri Pi security cam

Step 1: What Do You Need?

  • A Raspberry Pi ( I used B2 )
  • A Raspberry Pi Camera module
  • A SD card with 4GB or more ( I used 16GB )
  • A WiFi USB dongle
  • An USB keyboard
  • An USB mouse
  • A HDMI Cable
  • A Micro USB charger 5V ( I simply used a samsung phone charger )

Step 2: Setup Your Pi

First you need to download NOOBS [ Installation guide / files for mac/ linux /windows ]

As states in the installation guide you then need to extract the files to the sd card.

Now you can insert the sd card into the raspberry pi. Also connect the HDMI cable to a screen with HDMI support and plug it in your Pi.

Connect the keyboard and mouse. except if you just want to look at the installation screen.

Now you can power up your pi ! so plug in the micro usb charger and it will fire up automatically.

Wait for the installation screen to load, select Raspbian and hit install. ( takes a while )

Step 3: Seting Up WiFi and Static IP

Seting up WIFi Dongle

For the security cam to work wireless you will need to set some things up.

Make sure your Pi is powered off and insert your WiFi USB Dongle.

Power it back on and typ this into the terminal:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Now edit this file to look like:

ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdev
update_config=1
ap_scan=1<br>network={
ssid="YOUR WIFI NAME"
psk="YOUR WIFI PASSWORD"
}

And save the file using Ctrl + X, hit Y and then Enter

Static IP

If you want to access the cam you will need to make sure the address you use stays the same.

To make sure you are connected to wifi typ this into the terminal:

ifconfig

there should be a section that begins with wlan0 and contains a inet addr ( such as 192.168.x.x )

Write down inet addr, Bcast and Mask

Now typ

netstat -nr

look for destination and gateway that are not 0.0.0.0 and write those down.

after that it is time to set up the static IP

typ this into the terminal :

sudo nano /etc/network/interfaces

now there should be a line that starts with :

allow-hotplug wlan0

beneath that you should edit to look like the following:

iface wlan0 inet static
address [THE INET ADDRESS LISTED IN IFCONFIG]
netmask [ THE MASK LISTED IN IFCONFIG]
network [ THE DESTINATION LISTED IN NETSTAT]
broadcast [ THE BCAST LISTED IN IFCONFIG]
gateway [ THE GATEWAY LISTED IN NETSTAT]
wpa-config /etc/wpa_supplicant/wpa_supplicant.conf

Save the file : Ctrl+x hit Y and Enter

test the connection :

ping [THE INET ADDRESS LISTED IN IFCONFIG] -c 10

It should state that 10 packets are received.

Step 4: Installing the Camera

Now for the camera module.

make sure your pi is powered down.

Lift up the white part of the slot and insert the wire with the blue side facing the white bar and press the bar down.

Now fire your pi up again.

You now need to enable the camera. Go to the terminal and typ in ' sudo raspi-config '. navigate down and select ' enable camera ' then select ' enable '

For the camera to work as a webcam you need to change something. So go to the terminal again and typ:

sudo nano /etc/modules

and add the following to this file :

bcm2835-v4l2

Use Ctrl + X , then typ Y and hit enter to save the file.

Enable it by typing:

sudo modprobe bcm2835-v4l2

This will enable the pi to use the camera module as a normal webcam.

Now for the camera control.

make sure your software is up to date by typing the following into the terminal:

sudo apt-get update<br>sudo apt-get upgrade

After all is updated you can install the motion camera software:

sudo apt-get install motion

Now you can configure the camera by typing this into the terminal

sudo nano /etc/motion/motion.conf

There are a lot of options but you will only need the following:

daemon on
webcam_localhost off

Use Ctrl + X , then typ Y and hit enter to save the file.

Now typ this into the terminal :

sudo nano /etc/default/motion

And make sure the daemon is on autostart:

start_motion_daemon=yes

Use Ctrl + X , then typ Y and hit enter to save the file.

Make sure the camera is working by typing this into the terminal:

sudo service motion start

you should now be able to visit the stream by visiting your set IP address with port 8080 in your browser if you are connected to the same network.

if you don't remember your Pi's ip simply type ifconfig and look under wlan0

example : 192.168.1.37:8080

In the near future I will be adding a way for an extarnal live stream!