Attending makers! Are you looking for a challenging project that not just gets your gears grinding but helps to keep you secure while traveling? Welcome to the build-your-ain security camera tutorial.

The impetus for this projection originated from events that took place at Defcon 26, where hotel security staff inspected attendee rooms while not properly identifying themselves.

Gross overreach. Violation of your rights. Violation of your privacy. These are ever good motivators. The whole story is well covered here.

So our goal is to build a motion-activated security camera that we can use to monitor our own hotel rooms, homes, or other locations. Let's begin.

Choosing the hardware

While there does exist ready-made hardware that would satisfy my requirements, equally a quick web search demonstrated, I would demand to assess the security posture of each of these products. Whereas I tin can build satisfactory security into the hardware if I build it myself.

A selection of commercially bachelor portable spy cameras.

Building such a device should be possible with open-source software and off-the-shelf components. This should exist easy, correct?

After a quick rummage through my spare parts bin, I found a outset-generation Rasberry Pi.

Rasberry Pi classic

Afterward some careful consideration, I elected to have the captured video and stills saved locally. This device is going to be deployed on the virtually hostile network e'er, later on all. I could difficult wire it to the hotel network, or endeavor and provide information technology with cellular connectivity maybe by using something similar a nova global cellular modem.

I decided against it: Better to commencement small and limit the scope of the project. I can e'er add this functionality after, and using a cellular modem isn't a guarantee that the network traffic will not be tampered with or intercepted.

Later some research, I confirmed that the latest version of Rasbian (the official Rasberry Pi OS) notwithstanding supports the original Rasberry Pi. Further digging yielded 16gb and 32gb SD cards. Both of these would be well suited to the task. I started by performing a fresh install of the Rasbian Os to ostend that everything is okay with this Rasberry Pi. Information technology's been a few years and I had forgotten exactly why it had been disused.

I downloaded the latest version of Rasbian here.

Software and tools

I then extracted the 2018-06-27-raspbian-stretch.img from the raspbian-2018-06-29/2018-06-27-raspbian-stretch.cipher file, and used Etcher to copy information technology to said SD carte.

Etcher is a program that facilitates writing images to SD cards.

After inserting the SD carte du jour into the RPI and connecting a keyboard and monitor to it, I played around with information technology for a while. Once I was satisfied that, other than being a little sometime, everything was working, I added some heatsinks, as it is a cheap upgrade. I foresee the device running for several days in a row.

A simple heatsink kit available for the Rasberry Pi.

I besides took the opportunity to verify the exact model of Rasberry Pi I had. This was accomplished with the control: cat /proc/device-tree/model

The event was: Rasberry Pi Model b rev. 2

I as well dug up a cheap USB webcam I already had. The program was to use that to recycle erstwhile hardware and avoid additional costs. (More than after on why this was not a skillful idea for this particular project.) The webcam I had kicking around was a Logitech LZ241DV. I Researched compatibility on https://elinux.org/RPi_USB_Webcams. Information technology didn't show much promise.

A quick cntrl + F search on the page listing the Rasberry Pi compatible webcams and typing in the model of the Logitech camera. Cipher hits.

Choosing an Os

During my research for this project, information technology quickly became apparent that the virtually suited operating organization for this projection isn't in fact Rasbian, but motioneyeOS.

motionEyeOS is, co-ordinate to its github wiki, a Linux distribution that turns a unmarried-board reckoner into a video surveillance system.

Not only is motioneyeOS specifically tailored to our job, merely it has a Rasberry Pi–specific compiled version. I downloaded the appropriate versions for the hardware I accept on hand.

I installed motioneyeOS on a different SD card, connected the USB photographic camera, wired in a network cable, and plugged it into a test network I have in the lab.

To connect to the motioneyeOS Rasberry Pi, you can use a browser on any machine on the same network and only blazon the IP address of the motioneyeOS Rasberry Pi into the browser. So, you will be greeted with a web-based direction interface.

Simple diagram showing the topology of the motioneyeOS Rasberry Pi in relation to the machine used to configure it via the web interface.

Once the Rasberry Pi was fully booted, I ran a quick Nmap scan of the network on a machine that as well resides on the same network: nmap -sP 192.168.iii.0/24

Instance of the nmap control in bash to determine the IP address of the motioneyeOS

It is best to perform this nmap scan before and later on turning the Rasberry Pi on. The new address shown by nmap will be the instance of motioneyeOS.

NB: This IP address tin change betwixt reboots!

The web-based interface for motioneyeOS, showing the USB camera garbled video

If yous connect a monitor to the Raspberry Pi running motioneyeOS, it volition also display its IP at the prompt. As we tin see, the USB webcam doesn't desire to play video properly. I investigated on the web for a while, and tried routing the USB webcam through a powered hub. (This was one of the possible solutions I found online.) All to no avail.

At this point, to be thorough, I likewise downloaded the Raspberry Pi 3 image for motioneyeOS.

I flashed it on a 32gb micro SD card, temporarily decommissioned my retro gaming emulation projection, and tested the USB webcam on a current and known working Raspberry Pi 3. (The cool thing about this is that restoring that project volition only require swapping back my original micro SD card.)

Same results.

So the webcam isn't going to work without some serious picayune about. After giving this some more than idea, I elected to buy the Raspberry Pi specific camera. If I'1000 going to have to buy a camera of some sort, best to get i made specific for the Rasberry Pi in the first identify.

I settled on the Raspberry Pi Camera Module V2-8 Megapixel, 1080p. There are low lite versions of these cameras, but I want the college picture quality.

Troubleshooting

And this is where it gets messy. The module that came in the mail was either defective right out of the box, or I zapped information technology with static electricity early on.

I spent hours reinstalling Rasbian on the original Rasberry Pi, disconnecting and reconnecting the ribbon connector at both ends. I asunder the camera module from the mini daughter board and reseated it. Reinstalled motioneyeOS, disconnecting and re-connecting the ribbon once more. Repeated the whole process with the Rasberry Pi three, both in Rasbian and motioneyeOS.

This confirmed that the camera module was indeed dead on inflow (DOA). Zip I did yielded success. The best I could achieve was command line confirmation that the camera was present. The web interface of motioneyeOS always complained that the camera could not be initialized.

I decided to order a different camera module. I settled on the Keyestudio Camera Module 5MP REV one.3 for Raspberry Pi. Information technology is Rasberry Pi specific, but a unlike brand than my start endeavor.

This solved all the problems, and I was met with success on the first kicking try of the classic Rasberry Pi running motioneyeOS.

Successful video capture!

To have access to all the features and settings of motioneyeOS, you need to login as "admin."

The username and password should be changed to something not-default when you lot deploy this in your hotel room.

I also disabled the FTP server, the samba server, and the SSH server. I want to reduce the surface of attack for this device as much as possible. I can either recall the desired footage directly from the micro SD menu, or by re-enabling SSH afterwards.

If DHCP is enabled and the network cablevision is disconnected, the auto volition kick loop as it tries to renew an IP address.

In the advanced settings, you lot can too enable movement notification. This is where you would enable the actions to take place should a movement exist detected. This is too where you would configure the aforementioned nova cellular modem.

The final product

So there y'all have it. After some endeavour, we have a move-activated security photographic camera, congenital with off-the-shelf components and open-source software.

The finished product. (The screen is superfluous and was just used for configuration purposes.)

What lessons did we learn?

  • Don't presume the hardware yous have is working. It went in the junk pile for a reason. For instance, I wasn't able to up-cycle the USB webcam.
  • Micro SD memory cards are minor and easily misplaced. (I lost one during this experiment!)
  • SD cards can fail. I used the SD retentivity card formatter from https://www.sdcard.org to confirm this.
  • Fifty-fifty new hardware tin can be defective. I had a defective Rasberry Pi photographic camera. Information technology failed right out of the box. This forced me to practice a lot of detective work and examination all the hardware.
  • This wound up being quite a fleck more expensive than an off-the-shelf commercial product. It was a great learning experience, though.

What's left to practise?

I need to build a adept case for my Frankenstein security camera, because static electricity is a definitive business here. Exposed electronics is a not a proficient thing. Also the security staff, should it actually visit your room, might be alarmed at seeing a hodge podge of components and wires sitting on a desk.

There are several articles on the web describing how to build and deploy motioneyeOS on a Rasberry Pi. I e'er find that they never requite you the total story. Failures, both in hardware and software configurations, are an opportunity to learn.