Pi based security system

The Makerspace I’m a part of needed a security camera for insurance purposes.  Being a makerspace, we immediately over complicated things by deciding  to create our own system using a raspberry pi based DVR and some FOSCAMs.  The FOSCAMs became a problem that we had to limp through while we looked to stabilize our other requirements like a locking door and more members.   I eventually had time to give the camera system some love and this is what I came up with.

  • Pi-Zero 1.3  cameras running mjpg-streamer over ethernet (more on why ethernet instead of wifi in a bit)
  • An Atom based x86 PC running ubuntu and MotionEye handling DVR details
  • A PiBakery recipe to turn bare metal pi’s into security cameras with little intervention
  • Centralized and battery backed up power for everything

The overall costs comes to roughly $40 per camera, the rest of the stuff we had lying around.

  • $5 for the pi zero
  • 3d printed case or a $3 one from microcenter
  • $25 for the pi camera 2
  • $10 for the USB ethernet adapter and OTG cable

I glue magnets onto the case of the pi zero and we hang them off whatever metal is close by for mounting. If you use harddrive magnets, even sheetrock screws in the wall could do.

img_20161213_105215

For power, I wanted to make sure that the camera’s stayed online if we had an outage 313futzr-el(we’re a makerspace, blowing fuses is what we do) but didn’t want a powerstrip full of wall warts.  One of the members happened to have a 12v battery backup from an old phone system and I had a 12v to 5v @ 10amp converter sitting around.  We connected those up and ran low voltage cable to all of the camera locations, terminating it with a micro USB plug. The UPS looks like it should last us about 4 hours.

Originally I used Wifi on the pi’s. We have a good wifi setup at our space and I was able to get solid 720p at 30fps but our members started to complain of the wifi being slow. When I looked into it I found that 30fps 720p from 4 cameras all day every day turns into TBs of data over the wireless and I was bogging everyone down.  The switch to wired costs about the same as a wifi dongle anyway so I bought a handful and ran ethernet through the dropped ceiling to where the cameras lived.

pb2To get the pi zeros into good shape for streaming I used the experimental mjpg-streamer fork for the pi listening on port 8080.  To make deploying these as fast and painless as possible, I used pi-bakery to create a recipe that installs debian (full unfortunately, lite is having a dependency issue I haven’t found a work around for yet), configures wifi, a unique hostname, installs the dependencies, grabs the latest code from github, compiles it, configures it and sets it to run on boot. You can download my recipe here.  The recipe has been tested on pi 0, 1 B+, 2 and 3.

The DVR was the easiest part of the entire build. With ubuntu 16.04 on a small x86 machine, I just followed the install guide for MotionEye here and had a web based DVR up and running in a few minutes.

The forge now has complete coverage, night and day of our space entirely built around open source and we spent well under $300 to do it.  We finally found a use for all of the pi zeros that we had floating around and managed to use up some of those extra harddrive magnets we had been hording. If the pi camera turns out to be reliable I’ll 3d print some proper enclosures and see if we can figure out a better way to mount these.