This article will talk about how to assemble a low-cost IP camera based on the Raspberry Pi Zero W and the original camera module.
raspberry pi zero w security camera In principle, it was for this purpose that I originally planned to use the “mini-raspberry”. But the impressions of her work in this role were mixed.
I must say that such a device fulfills its cost. But a miracle did not happen and it did not work to get an analogue of an industrially produced IP camera for less money.
Well, read more about everything further in the article.
What do we need
To implement the steps described in this article, you will need:
- Raspberry Pi Zero W + case + CSI cable
- Raspberry Pi Camera Board V2 or Raspberry Pi NoIR Camera Board V2
- The local network
Optionally, you may need a separate device for the DVR. It will be needed if there is a need to use 2 or more CCTV cameras in one complex.
Almost any computer running Linux or even Windows can be used as a DVR.
Raspberry pi zero w camera assembly

Everything needed for assembly is a Raspberry Pi Zero W microcomputer, a microSD-card with a system image, a body with a hole for the camera’s eye, the camera module itself and a loop from the full-sized CSI connector to the miniature CSI used in Zero and Zero W.
Using a loop, we connect the raspberry pi zero camera module to the microcomputer.
place the Raspberry Pi Zero W at the base of the case.
fix the camera module under the cover on the plastic latches intended for this.
combine the cover with the base of the case, and the assembly process of the IP camera can be considered completed.
Unfortunately, no attachments for mounting on the Zero W chassis are provided. But the main thing is to decide where the camera will be permanently located, and you can always think of a mount.
For the duration of the experiments, I simply attached it to the window glass on tape.
Option 1: Raspberry pi MotionEyeOS
The easiest way to use the Raspberry Pi as a network camera is to use the MotionEye application .
MotionEye is a video surveillance server based on the Motion console utility. Which, in turn, allows you to recognize the movement in the video stream from the camera and output this video stream to the open port of the web server.
MotionEye can be installed on any Linux-based computer as a regular application, and on Raspberry Pi and some other single-board computers it is also possible to use the ready-made assembly of MotionEyeOS – a minimalistic Linux distribution that weighs only 230MB and does not contain anything except MotionEye itself and a minimal amount packages necessary for its work.
I believe that it is more convenient to use a ready-made assembly for an IP camera. After all, we will not make a multitask device from the camera, and if so, it is more correct to install the most lightweight version of the system.
Therefore, download the system image from this page and write it to the microSD-card like any other Linux distribution for the Raspberry Pi
Then we create the wpa_supplicant.conf file with the following contents:
ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev
update_config = 1
country = RU
network = {
ssid = "WIFI ACCESS POINT NAME"
psk = "WIFI PASSWORD"
key_mgmt = WPA-PSK
}
And we throw it into the root directory of the memory card with the recorded image. This is to ensure that Zero W automatically connects to the wireless network.
Then we find the local IP address of our camera on the local network, and open it in the browser.
And before we opens the MotionEye web interface with an already working camera.
To access the camera’s video stream and system settings, you need to log in as admin with an empty password. In the future, you can set your password in the settings.
By the way, the settings are quite extensive. We can:
- Change the resolution and frame rate of the video stream
- Enable or disable motion detection system on video
- Set a place for storing videos, which can be either your own Zero W memory, or a shared network resource, an FTP server on the Internet, or Dropbox and Google Drive cloud storage
- Codec to be encoded video
- Connect additional cameras, including network cameras, supporting RTSP or MJPEG protocols
- Record not only video, but also photos with a given frequency (or by triggering a motion detector)
- It is flexible to configure the camera module itself, including changing ISO with exposure
- Stream from the camera to a third-party video server
In general, the thing is quite serious. It may not be as much as commercial video recording systems, but most likely MotionEye capabilities will cover all the needs of a home user regarding video surveillance.
What about the flaws? And the main drawback is that Motion on the Raspberry Pi does not know how to use hardware acceleration. Therefore, the entire load when working with the video stream falls on the processor – far from the most powerful even in the third “raspberry” and frankly weak in Zero and Zero W.
Let’s just see examples of videos made through MotionEye on Zero W:
(By the way, for some reason, these recordings are played differently in different players. For example, in the omnivorous Media Player Classic, high-resolution videos go like a very slow slideshow, while in Lister – the file viewer built into Total Commander – they play much better and with a higher frame rate. It will be necessary to experiment with the choice of codecs for compression)
What do we see? A video stream with a resolution of 640 × 480 pixels is well written, video in a resolution of 800 × 600 is almost normal. Raspberry Pi Zero W is already not enough on video in higher resolutions of processor power and fps drops to 2-3 frames per second.
So you have to compromise by choosing between video resolution and frame rate. Well, you can forget about the ability of the Raspberry Pi Camera Board to shoot in fullHD resolution: it can shoot, but the video stream will not have time to process, therefore, in this resolution, you can only rely on photofixing.
Option 2: Raspberry pi RTSP stream to a third-party device
Another option for using the Raspberry Pi Zero W as a camera is to stream the video using the RTSP protocol to another device that functions as a DVR.
To do this, we will no longer need Motion, but VLC Player and the raspivid console utility, which I wrote about in the review of the camera module .
Install the vlc package in Raspbian:
sudo apt-get install vlc
And we start broadcasting the video stream:
raspivid -o - -t 0 -n -w 640 -h 480 -fps 30 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
The parameters -w and -h set the video resolution (width and height, respectively), and the -fps switch limits the maximum frame rate.
The video stream will be available on the network at rtsp://ip-address-rpi-zero-w:8554/ . It can be integrated into any video surveillance application, or viewed through video players that support network playback – for example, the same VLC Player or Media Player Classic.
According to the RTSP protocol, video goes without such drawdowns as fps as in Motion, but another problem arises: it is broadcast with a delay of 3-5 seconds.
Option 3: MotionEye (client) + MotionEye (server)
Another option is to install MotionEye on the Zero W as a client module, and deploy MotionEye on the other device as a DVR server for recording and broadcasting video. And connect them over the network.
This will reduce the load on the Zero W processor (especially if you activate the option (“Fast Network Camera”) in the MotionEye settings.
Conclusion
The obvious advantages of such a homemade camera include the cost. The microcomputer itself costs about $ 25, another $ 20 per camera, in total, the device costs us $ 45, or about 2700 rubles at the current rate. An average IP camera in Russian retail will cost 2-3 times more. Minimum.
Another definite plus – compact dimensions. The camera described in this article is easy to hide. And although in general our legislation negatively refers to covert video surveillance, a person has the right to install cameras within his own home (which is not a public place) as he sees fit.
Well, minus is the video quality. It will not satisfy demanding users.
In general, we can say that such a device fulfills its money. But I expected a better result
Leave a Reply