Categories
Linux Raspberry Pi

Homemade security camera with a Raspberry Pi

One week ago we’ve had a burglar in our house. Of course I immediately started improving the security of our home. After improving the usual stuff I felt the need for some kind of security camera. This camera could provide me a good view of the backyard which is a very quiet place and therefore preferred by burglars. Because I like to make things myself I thought it was a good idea to use a Raspberry Pi and it’s camera module. I used them in the past for time-lapse video’s of scenery but I hadn’t used it much lately.

The goal that I had set was a camera that detects and records motion and that I could access through our local network preferably a browser. I also wanted the camera to give decent images by day and night.

Hardware.

The heart of the system is a Raspberry Pi B with the Raspberry camera module. Furthermore I use an Edimax dongle for my Wi-Fi connection and a micro-USB power supply (1A). Initially I use an MDF case that I made to fit the camera and the Pi. It isn’t pretty but it protects both the camera and the Pi. If everything works as planned I probably built it into a dummy camera such as this one or may make a wooden enclosure myself.

Initially I had some problems connecting to the Pi through SSH. I discovered that this was caused by the Edimax dongle (8192cu Wi-Fi chip) that apparently goes into sleep mode after a period of inactivity. This was solved with a command line fix that disables power saving (see here on page 17 how to fix this).

Raspberry Pi in DIY camera case made of MDF.

Software

On top of Raspbian I installed Motion. Motion is a Linux program that monitors the video signal from camera’s and, very important to me, is able to detect motion. Motion is widely used and there is plenty of good information on it on the internet. A simple tutorial how to install Motion specifically on the Raspberry Pi and get it to work with the Raspberry camera module can be found on here (go to step 7 for software installation). However Motion has far more possibilities and it is worthwhile to explore these once you start using it.

Configuring and testing the system

Motion can support multiple camera’s but I’ll stick to one camera for now. Configuration of Motion for the Raspberry Pi and it’s camera module is done in the /etc/motion.conf file (not in the /etc/motion/motion.conf file). There is a very good YouTube tutorial on configuring Motion for Linux here and here. At this point I made only a few changes to the motion.conf file such as camera width and height, directory where the video is stored on the Pi and some camera specific variables.

The camera works great. The image quality is good and the system appears to be stable. I can open a stream of the security camera in my browser by entering the URL of the Raspberry Pi and the selected port (default 8081). My motion files are stored as avi’s on the Raspberry Pi. I can play them with VLC media player on my iMac. Next I’ll experiment with the settings of Motion (e.g. sensitivity of motion detection, resolution of the camera), test in under different circumstances (indoor, outdoor, night and day) and build a proper housing for the security camera.

The finished security camera
Categories
Linux open source PC

DIY streaming media box: building it.

Building the streaming media box consists of a hardware and a software part. Building the hardware is relatively easy. With these modern PC components you can’t do much wrong. First I inserted the 4Gb DDR3 memory into the motherboard. In my earlier post on this topic I mentioned that I already had a MSI mini-ITX motherboard and a processor (Celeron G1610) from my sons PC that I upgraded earlier. With the motherboard ready, I removed the power supply from the LC-1410mi case. The motherboard fitted nicely over the six elevated mounting points in the LC-1410mi.

When I inserted the power supply I noticed that it blocks the PCI slot on the far side of the motherboard something I hadn’t that seen coming (see image below). I therefore was unable to use the PCI Wi-Fi card that I had. I decided to use a USB Wi-Fi stick that I already had. It is not as elegant as the card but it works.

Next I connected all cables from the power supply and the case to the motherboard. When you do this for the first time it can be intimidating because of all the different connectors on the motherboard. Luckily cases and motherboard generally come with descriptions of all these different cables and connectors. I connected the 128Gb SanDisk SSD to the motherboard SATA port with SATA cable and to the power supply. The 2,5 inch SSD didn’t fit into the bracket that comes with the LC-1410mi. I had to improvise to get the SSD into the case.

With all hardware built-in and connected I decided to test the system. I connected a monitor, keyboard and mouse and booted the streaming media box in the making. Since the SSD was still empty I was only able to enter the motherboard boot-menu (on MSI press F11 to enter the boot-menu while booting). This is sufficient to test the hardware and all the connections. The whole system appeared to be functioning okay.