I’ve been wanting to build a couple of home automation projects and that’s going to
be the theme for some of the upcoming project videos. Today, let’s talk about video surveillance.
If you’ve been following along with the videos, then you will know that we have built
some surveillance projects using the ESP32-CAM board. And although the board is really compact
and cost effective board, the image or video quality is not exactly great.
Using the motionEye OS for the raspberry Pi is a very popular alternative and, in this video,
we will learn how to set it up and we will also evaluate it to see if it is good enough
for the job. So let’s dive in.
I’ll be using the raspberry pi zero W, but you can also use any other variant that you
may have. You will also need a microSD card, a suitable power supply and camera. I’m
using v2 of the official camera module and if you are also using the pi zero W then you
will need to get this adaptor cable as the camera connector on the Pi zero is different
compared to that on the full sized raspberry PIs. The camera mount is option and I picked
this one up from the pi hut. You will also need a way to access the microSD card from
a computer. If your computer has an SD card slot then you can use an adaptor like this or you can
simply get a usb card reader as well.
We used the Arduino IDE to program the ES32-CAM board however, the raspberry pi needs an operating
system for it to function. This operating needs to be loaded onto the microSD card.
We will be using motioneye OS for this video so head over to the motioneye OS wiki
and click the supported devices link. This gives you a list of all the supported boards
and you can download the latest version for your particular raspberry pi board. The next
step is loading this image onto the microSD card and for this, we will use etcher. Download
and install it to your computer. Plug in the card reader, select the image that we downloaded
in the previous step and make sure you have the right drive selected. Finally, hit the
flash button and wait for it to complete.
The motioneyeOS creates a surveillance system and the camera feed is accessible through
the network. For this to fuction, it first needs to connect to the network. If you are
using a board that has an ethernet connection, then you can simply plug in an ethernet cable
to the board and connect the other end to your router. If you are using a standard router,
then you would need to change any settings on the board.
The pi zero W does not have an ethernet port but it does have built-in WiFi and that’s
what we need to configure next. We can do this by creating a file with this name in
the boot drive. You can create the file using a text editor like notepad++ and make sure
you add the correct extension. The project post on the website will have a link to the
template file that you can download and update with your network details. Simply open it
up with a text editor, add your wifi network details and then copy this to the boot drive.
Once done, eject the microSD card and insert it into the raspberry pi.
Before we power on the board, let’s connect the camera to the raspberry pi. The tabs on
the connectors are fragile, so be careful when working with them. You do not need a
display to run motioneyeOS, but if you have one then it would make sense to connect it
when you first power on the board. This will allow to view the status. Here’s what the
output looks like. It did take a while for the board to connect to my WiFi network so
keep that in mind. The board will take about 2-3 minutes to complete some additional
tasks when it is powered ON for the first time so do not disconnect it during this process
or else you will have to start over by a re-flashing the OS image to the microSD card. If for any
reason the board cannot connect to the network, then it will restart and you will be able
to tell if it has restarted by keeping an eye on the power LED. If everything is successful
then the board will connect to the wifi network and print out it’s IP address. However,
if you have not connected a display then you will have to use some other way to obtain
the IP address. One way to do this is by logging into your network router and checking the
client list. The other way is by using a network IP scanner and that is what we will do next.
An IP scanner simply scans all the IP addresses on your network and displays any active devices.
There are many such scanners available and I will be using Angry IP Scanner for this
video. Download and install it to your system. You will also need to install Java so simply
follow the instructions for this. Once completed, open up Angry IP scanner and hit the start
button. Wait for it to complete. You will be able to see a device called meye- followed
by more characters and this is the motioneye board. Keep a note of the IP address. If the
board is not visible after 5 minutes, then it most likely has failed to connect to the
network. You can power down the board, remove and insert the microSD card into your computer
and copy the wpa file again. Make sure the details are correct and insert the microSD
card into the board to try again. If it still fails, then it would make sense to connect
a display to the board or to start over one last time by re-flashing the image. The board
needs to be on the network and you should have its IP address in order to move to the
next step.
The board can be controlled using its IP address so open up a web browser and type in the IP
address. You should see a stream like this. By default, you are not logged in and you
will only have access to minimal settings. So click this icon here and enter your login
details. The default username is admin and there is
no password. Once logged in, you will gain access to a lot more settings so enable the
advanced settings to allow you to change many more options. First, let’s take a look at
the video device section. You can rotate the camera as per your needs and this gives you
a bit of flexibility when it comes to mounting the camera. Apart from this you can change
the framerate, resolution, camera name and so on. Now that we have corrected the video
feed orientation, let’s take a look at the interface. You can add multiple cameras to
the system though I have not done this and I’ll get to the reason why towards the end
of this video. The preferences section is mainly for the layout, when you have multiple
video feeds.
The general section takes care of things like username, password and such. I’d recommend
adding a password to the system if you plan on using it. You then have the network, services
and expert settings which I have not really used. We’ve already taken a look at the
video device options. The motionEyeOS can also capture and store images or video files.
You can also specify the file location for saved media and this could either be the microSD
itself, a USB storage device and you can even upload it to a network drive or cloud storage.
As you can see, you have a lot of options to customize this as you like. You can change
the text overlay as well as the video streaming options. Keep in mind that the streaming quality
is different from that stored as media files.
The motionEye OS also allows you to detect motion and when this has been detected, you
can either tell it to capture still images or video or both. You can enable motion detection,
specify the thresholds and such and you can also schedule notifications. With regards
to still image capture, you can specify the quality, capture mode which can be motion
triggered. You can do the same thing for movies and you can even set it to record continuously.
You can also set the board to delete movies after a certain time interval. Finally, you
have the working schedule which allows you to control when the camera is active.
Let’s quickly test the motion detection system. We enable motion capture and set it
to record 10 second videos when motion is detected. Hit the apply button and this should
be active now. If you hover over the video stream, you will see two icons which allows
you to browse the still images and videos. You can browse the videos, play them back,
download or delete them which is very convenient as you do not need to remove the microSD card.
Now that you’ve seen how to use motioneyeOS, let’s talk about the things that I do not
like. The biggest thing is the video lag. I’ve played around with the settings a bit
and this doesn’t seem to improve. It’s the same for the recorded files. Though this
is acceptable to an extent, it is not ideal for what I’m looking for. You would probably
get a much better experience running in on the raspberry pi 4 but then again it costs
a lot more, and is bulky compared to the pi zero. In my opinion, the reason for this is
that motioneye OS converts the raspberry pi into a full-fledged surveillance system. It
tries to do the video capturing, processing, saving, exporting, and many other things.
In actual surveillance systems you generally have dumb cameras that only provide a video
stream and all the processing, storage, exporting and so on is done by a central system also
called a network video recorder or NVR. That’s the approach I would like to take. Keep in
mind that if you are going to store media files onto the local microSD card, then you
will need one of a sufficient size which also increases cost for a multi-camera setup.
I’d much rather use the pi zero to do just one thing and that is to stream video over
a network, ideally using RTSP. You can then use one raspberry pi 4 or an old computer
to access all the video streams and manage them. It wouldn’t be as easy as using the
motionEye OS but if you are trying to build a surveillance system using the Pi zero, the
it is definitely something you need to consider.
So that’s my take on the motioneye OS. It’s a very interesting piece of software that
allows for a lot of flexibility, but it probably needs much more powerful hardware for it to
run as intended. In the next raspberry pi video, we will learn how to build a simple
IP camera that streams video using RTSP. Since the Pi zero will only be doing that, it should
be able to stream at a much higher resolution and frame rate compared to today’s tests.
I haven’t worked on it yet, but I think it’s totally possible so do subscribe to
stay updated, if you haven’t already. Thank you for watching and I will see you in the
next one.