Membangun CCTV dengan raspberry-pi

27 Jan

Membangun CCTV dengan raspberry-pi

webcam2 webcam

1. cek apakah usb camera ter-detetct raspberry
pi@raspberrypi ~ $ sudo su – root
root@raspberrypi:~# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1871:0142 Aveo Technology Corp.
Bus 001 Device 005: ID 1871:0142 Aveo Technology Corp.

root@raspberrypi:~# dmesg | grep video
[   18.262096] Linux video capture interface: v2.00
[   18.431822] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1871:0142)
[   19.063984] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1871:0142)
[   19.471164] usbcore: registered new interface driver uvcvideo

2. install paket motion
root@raspberrypi:~# apt-get update
root@raspberrypi:~# apt-get install motion

3. edit /etc/motion/motion.conf
a. ubah
webcam_localhost off

b. ubah
control_localhost off

4. jalankan servicenya motion
root@raspberrypi:~# /etc/init.d/motion start

5. buka browser http://172.20.x.x:8081

motion_01

6. kalau pasang 2 usb webcam
a. matikan servicenya motion
root@raspberrypi:~# /etc/init.d/motion stop

b. install apache
root@raspberrypi:~# apt-get update
root@raspberrypi:~# apt-get upgrade
root@raspberrypi:~# apt-get install motion
root@raspberrypi:~# apt-get install apache2
root@raspberrypi:~# apt-get install emacs

c. buat file untuk kebutuhan motion.conf
root@raspberrypi:~# nano /home/pi/cam1.conf
videodevice /dev/video0
text_left USBWebcam-1
webcam_port 8081

root@raspberrypi:~# nano /home/pi/cam2.conf
videodevice /dev/video2
text_left USBWebcam-1
webcam_port 8082

d. edit /etc/motion/motion.conf
thread /home/pi/cam1.conf
thread /home/pi/cam2.conf

e. buat file
root@raspberrypi:~# nano /var/www/webcam.html
<html>
<head>
<title>Raspberry Pi Webcameras</title>
</head>
<body>
<h1>Raspberry Pi Webcameras</h1>
<a href=”http://172.20.x.x:8081/”&gt;
<img src=”http://172.20.x.x:8081/&#8221; alt=”Camera 1″ ></a>
<a href=”http://172.20.x.x:8082/”&gt;
<img src=”http://172.20.x.x:8082/&#8221; alt=”Camera 2″ ></a>
</body>
</html>

f. jalankan servicenya motion
root@raspberrypi:~# /etc/init.d/motion start

g. buka browser http://172.20.x.x/webcam.html
motion_02

7. agar motion selalu start setiap kali booting, edit /etc/init.d/motion
a. ubah
[ -r “$DEFAULTS” ] && . “$DEFAULTS” || start_motion_daemon=yes

8. Setiap perubahan oleh motion di raspberry disimpan di /tmp/motion dan setiap kali booting /tmp/motion dihapus
root@raspberrypi:~# ls -la /tmp/motion/
total 5660
drwxr-xr-x 2 motion motion    4096 Jan 22 14:50 .
drwxrwxrwt 5 root   root      4096 Jan 22 14:59 ..
-rw-r–r– 1 motion motion 2377479 Jan 22 14:13 01-20140120161747.swf
-rw-r–r– 1 motion motion  777632 Jan 22 14:11 01-20140120161748.swf
-rw-r–r– 1 motion motion   10450 Jan 22 14:07 01-20140122140706-00.jpg
-rw-r–r– 1 motion motion   12082 Jan 22 14:09 01-20140122140916-00.jpg
-rw-r–r– 1 motion motion   34659 Jan 22 14:13 02-20140122141243.swf

9. Agar file – file tersebut tidak hilang dapat disimpan ke server ftp, lakukan perubahan di /etc/motion/motion.conf
root@raspberrypi:~# nano /etc/motion/motion.conf
tambahkan

; on_picture_save value
on_picture_save wput –binary –remove-source-files ftp://userku:passwodku@ip_server_ftp %f

10. motion menangkap perubahan dan kirim email
10a. install postfix
root@raspberrypi:~# sudo apt-get install postfix

10b. Tambahkan /etc/postfix/main.cf
root@raspberrypi:~# nano /etc/postfix/main.cf
# Forward mail through Gmail
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

10c. Tambahkan /etc/postfix/sasl_passwd
root@raspberrypi:~# nano /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 user_email@gmail.com:passord_gmail

10d. Change permissions and enable sasl_passwd
root@raspberrypi:~# sudo chmod 400 /etc/postfix/sasl_passwd
root@raspberrypi:~# sudo postmap /etc/postfix/sasl_passwd

10e. Validating the certificate
root@raspberrypi:~# cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

10f. Restart Postfix
root@raspberrypi:~# /etc/init.d/postfix reload

10g. test postfix
root@raspberrypi:~# echo ‘hi’ | mail -s ‘Test’ setijo@gmail.com

email
10h. Agar kirim email, lakukan perubahan di /etc/motion/motion.conf
root@raspberrypi:~# nano /etc/motion/motion.conf
tambahkan
on_event_start  echo Movement has been detected on: `date +”%m/%d/%Y %H:%M:%S”` | mail -s ‘Motion Server’ setijo@gmail.com

2 Responses to “Membangun CCTV dengan raspberry-pi”

  1. azki April 11, 2014 at 8:02 am #

    infornya bagus tapi saya masih sedikit binggung. mungkin karena belum saya coba dan belum memiliki raspberry.🙂

  2. arza June 5, 2014 at 6:41 pm #

    mas,, saya udah coba yang menggunakan 2 kamera,,, tapi kok pas searching gambarnya gak tampil… mohon pencerahan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: