Raspberry Pi: build a surveillance camera and web server - how it works
Even if it sounds complex - with a Raspberry Pi you can build a web server and a surveillance camera very quickly. We explain the exact procedure in this article.
Raspberry Pi: Set up your own web server
You can easily use the Raspberry Pi as a web server, whether for classic websites or for surveillance cameras.
- To do this, first execute the "ifconfig" command in the terminal and note the IP that is in the "eth0" section after "inet addr:".
- Then install Apache using the "sudo apt-get install apache2" command. You should also install PHP and MySQL using the "sudo apt-get install php5 mysql-server -y" command.
- To load your own website into the server, use the "sudo chown -R pi / var / www / html" command to give yourself access to the folder. In this folder you will already find a file called "index.html", which you can adapt to your requirements.
- To access the server, use an Internet-enabled device that is connected to your network to call up the IP address noted at the beginning in the browser.
Set up web server for surveillance camera - in 10 steps
To build a surveillance camera with the Raspberry Pi, which is also accessible via a server, you need the Raspberry Pi camera module, which you can plug into the port provided on the Pi.
- Then start the "Raspberry Pi Configuration" and activate the camera under the "Interfaces" tab.
- Use the commands »sudo modprobe v4l2_common« and »sudo modprobe bcm2835-v4l2« to install two small Video4Linux modules.
- Then add them with the commands »echo" v4l2_common "| sudo tee -a / etc / modules «and» echo "bcm2835-v4l2" | sudo tee -a / etc / modules «to the / etc / modules file.
- If you now use the »ls / dev / video *« command to display the video devices, the camera should also appear.
- In the next step, use the "sudo apt-get install motion" command to install a tool called "Motion" and edit the configuration file with "sudo nano / etc / default / motion". Enter the "yes" command in this "start_motion_daemon =" and save the file.
- Also create a new directory with the command »mkdir / home / pi / cam« and enter it with the commands »sudo chgrp motion / home / pi / cam« and »chmod g + rwx / home / pi / cam« necessary rights.
- Now you have to edit the motion configuration file with »sudo nano /etc/motion/motion.conf«. Set the "daemon" to »on«, select "target_dir" »/ home / pi / cam« and set the "stream_localhost" to "off". Tip: You can search for certain settings with [CTRL] + [W].
- Then select "640" as "width", "480" as "height" and "10" as "framerate" so that the images are not delayed when the Internet is slow.
- Now select the value "5000" as "threshold", set "ffmpeg_output_movies" and "output_pictures" to "off", set "8081" as "stream_port", "75" as "stream_quality" and "10" as "stream_maxrate" " firmly. Finally, set the "stream_motion" to "on".
- Finally, start the surveillance camera with the "sudo service motion start" command. To access the stream, enter the noted IP and the suffix ": 8081" behind it (as a port) in the browser.
In the next practical tip we will show you how you can build your own NAS with the Pi.