Are you tired of your dog chewing your
shoes while you’re not around? Let’s build a camera to catch it red-handed.
My name is Kradion, and this is Maker’s Report. It would be nice to have an extra
pair of eyes. Unfortunately, the only ones we have are firmly attached to our head.
So, if we want to do better we need to use technology. In this episode we are
going to build a simple and inexpensive security camera based on Linux. Something
simple, if you want to monitor your aquarium while you’re on vacation,
or if you want to make sure that nobody messes with your lunch box during the
break. So, without any further ado, let’s move to the project plan. Okay, here we are.
I took a few notes of important points that I want to have in this project. So,
first of all this project has to be inexpensive. I want to just buy a few
components, not spend too much money, I want this project to be simple
and accessible to as many people as possible. I want the camera to start
automatically and configure itself automatically. I don’t want to mess
around with network configuration and motion detection configuration,
nothing like that. I just want to take my camera, connect it to a power source, and
we should be ready to go. Then, very important, I want to be able to connect to
the camera through my local network and watch the live video feed. Basically I
want the camera to be used as a proper network camera. Then, of course, it’s a safety
and security camera so it has to provide motion detection, and I want that every
time motion is detected in the image an alert is sent via email, which should not
be complicated, I hope. Then, I would like it to provide a certain degree of night
vision. Now, I think this would greatly increase the flexibility and usability
of the camera. Now, if proper night vision is not possible, minimum would be an
enhanced vision mode that we can use for example when there is a poor lighting
condition, exactly, so having it work in poor lighting conditions will be perfect.
And then last, but very important, no custom hardware.
I want instant gratification for this project, I do not want to build any
custom casing, any custom electronics, I just want to buy components, configure
them, put them together, and have the functionality I need, so anything that
cannot be done with off-the-shelf components will not be done in this
project. And then I wrote it here a couple of nice to have, one would be to
have multiple cameras connected to the same system. Basically to have a
centralized way to control several cameras, to have a network of security
cameras. I think that would be very cool. And then last, having the
possibility to send SMS alerts when motion is detected.
Now, this is truly, absolutely useless, I know, but I think it would be cool to
learn how to do it properly, so I think now is the time to do some shopping. Okay
so we are back from our shopping session. For this project I have decided to use a
Raspberry Pi Zero W. Now, this is a very interesting single board computer
because it is able to run a full-fledged Linux system, which means that we can
download and install any compatible Linux distribution on this 8GB
Class 10 micro SD card, and it will boot just fine, which means that we can
use any Linux compatible surveillance or motion capture software. This is going to
be great in my opinion. Now, this board has also the big advantage that it
supports natively Wi-Fi. It has an embedded Wi-Fi system, which means it is
going to be very easy to connect to the to the local network. But the most
important feature of this board is this connector up here. This is a camera
connector that is compatible with the official Raspberry Pi camera, which I
bought. This camera is the no-IR version, which is an 8 megapixel camera
that has been deprived of the near infrared filter. This means that this
camera is quite sensitive to low levels of illumination and to near-infrared
light, which means that we can use it as a night-vision camera or a low-light
camera. Now, the consequence is that colour rendition would be imperfect for
daytime imaging, but we are not after pretty pictures. So, this should work
quite fine. Now, this cable is way too long for us so I also got a shorter
cable that can be used with the Raspberry Pi Zero, so this is going to be working just fine. Now,
in order to use it properly we also need a proper casing, and I found that the
official Raspberry Pi Zero case is actually exactly what we need. It’s small, it’s plastic,
it’s very inexpensive, and it comes with several tops; one of them has a hole
compatible with the camera, so we can build a camera around this, I think,
presume. Now, the only regret I have is that this case is built in very flashy
colour, very bright colour, which is not exactly ideal for a security camera
that should be quite discreet and not very visible, but I think for this type,
for this prototype, I think it can work. Last component, of course, we need to
provide power to the camera, so I got this micro USB charger that can
provide up to 2 amps of power for the entire camera system. This is going to be
the only connection for the system. And last, but not least, rubber feet: because
every project needs rubber feet. So now we can move on to the software
implementation. And the only software we need is a
custom Linux distribution called MotionEyeOS (link in the description). Just
download the image version for your hardware and get the writeimage script,
then follow the clear installation instructions. Can’t go wrong. the writeimage script allows me to pre-configure the Wi-Fi connection, which is kind of
handy considering the Raspberry Pi Zero has no Ethernet plug, and that MotionEyeOS
can only be accessed from a web interface, so keep your network
configuration at hand. And of course you really want to make
sure you point the writeimage script to the device file of your microSD card.
Like dd this command may wreak serious havoc on your machine if you make
mistakes, so read the command line twice before pressing enter. You have been
warned. Once done, you can proceed to insert the precious memory in the
capable board. Ah, nice feeling… Then you want to connect the camera. Slide
carefully the narrow end of the flex cable into the connector, contacts facing
down, and carefully clip the black latch in position with your finger. Now be
careful with the latch. It’s plastic, it’s fragile, and it will break on you while
you’re recording a YouTube video, so, yeah… Next you want to clip the camera on the
other end of the flex cable. Same procedure, just make sure the camera is
facing down, as we will flip it during assembly later on. Next, if you need
direct access to the device during configuration, you want to attach a
microUSB to USB adapter. Pay attention to which port you connect the adapter to.
The port closer to the camera only provides power, so you want to use the
other one. This will save you a great deal of debugging later on. Also, the
Raspberry Pi Zero has only a micro HDMI port so, if you want to connect a monitor,
you need an adapter for the adult size of HDMI. No big deal.
Last, we need to connect the power supply to the correct port, cross our fingers, and
wait for a solid green LED. Okay, nice. Now, I can go back to my
computer and connect to the IP address I specified while flashing the image on
the card. Apparently I’m greeted by a seriously
pissed owl, and I’m in the camera control panel. So, where’s the image? Oh, the camera
is facing down! There we are. So, framerate sucks, and colours are indeed
washed out, but it’s a first step. Now I can configure the camera to my likings. [Evil laughter] The camera has a truckload of settings. I
will not cover them all, I mean, you can have fun on yourself. There are a few
though that I think require attention. First of all you want to save all
captures to a remote location. For my test, I choose to transfer all files to
my Google Drive. This means that your precious evidence will be safe even if
the invader finds and destroys the camera. Take that, imaginary thief! Then,
you want to configure motion detection. Now, setting these parameters is kind
of a black art. It’s more cooking than science. Just test around until you find
a compromise between the paranoia of continuous false negatives and the
annoyance of continuous false positives. Good luck. Last point, you can send all
alarms and notifications to a specified email address, so we’ll do that. Okay, fingers crossed. Let’s put it together and see if it works. Putting the camera together is a snap.
Literally. You just snap the camera in the case lid, snap the board on the case
body, and snap the two halves together. Boom, done.
Easy as pie. Now, back to the computer, it’s time to
test the basic functionality. I have already seen the live video feed from
the camera, so the network camera functionality is basically covered. Time
to test motion detection. Whoa, this bird… So, I installed the camera in my living
room, and now I think I’ll just walk in front of it.
There we go. The motion has been detected and the camera started recording data
and footage. I can see the frame rate has dropped quite dramatically on the live
view, but I can tell you that the final result actually contains enough pictures
to clearly follow what’s going on, so it works! To test night vision I’ve bought a
very cheap infrared lamp on Amazon. Now, I like this one because it has an embedded
light sensor. This lamp turns on automatically when it gets dark, which is
convenient, so back to the test it is now time for total darkness. Bam! The infrared
picture is surprisingly clear. I was not expecting that. And we can see that
motion detection seems to work perfectly also in the dark, so yay.
That’s another success. OK, so, incredible… All basic functions seem to work.
Let’s have a look at some extra functionality. One camera is nice, but you
know what would be better? Two cameras, and a centralized way to
manage them, of course. To pull this off, we need a central controller, and I
think I happen to have just that. I grabbed a regular Raspberry Pi 3 board
and I have installed MotionEyeOS. Let’s see if I can use it as a hub for
our cameras. Well, it turns out that MotionEyeOS can do just that.
We simply need to connect to the hub device, write our credentials, hello angry
bird, add a new camera, select remote MotionEye camera, and provide the IP
address for the two satellite cameras. And bam! Instant security network.
This was so easy it was almost disappointing. Anyway my last wish in my
list of wishes was simply to set up SMS alarms. This was also very easy.
I subscribed to a service called tesxtlocal (link in the description) and used
their API to send SMS from the interwebs. They have a very simple example in
Python that I have copied to my cameras. I pointed MotionEyeOS to execute my
script upon motion detection, and saved the configuration. Will it work? Let’s see… Yep, there it is. An out-of-focus SMS from
the triggered camera. Boom. Mission accomplished. So, here we have it, a small,
inexpensive, Linux based, security camera. All in all and quite happy with the
result of the project. I think I could implement most of the functionalities
that I wanted, so it was a success. What would you do differently? And how would
you use this type of device? Let me know in the comment section. As always, thank
you very much for watching, and if you like this type of content, feel free to stick around for more. My name is Kradion, and this was Maker’s Report.