Building up to the Raspberry Pi

Raspberry_Pi_LogoI’ve been hitting the Raspberry Pi and Arduino pretty hard lately.  I plan to detail my projects some here in the future but I figured it would be good to start off with a little “why” and a little history.  I mentioned the Arduino, but I only plan on touching on the Raspberry Pi here today.

I’ve used a secondary PC for projects for a very long time now.  A second or third or even fourth PC an be extremely useful for learning more about PCs.  The main nicety is that if you want to completely wipe it out, you don’t have to worry about what to do with your important data on your main PC.  Want to try a new Linux distro?  Screwed up some configuration?  Just reformat and try again.  You can do some of this with Virtual Machines but that can mean sharing resources which isn’t always a good solution.  Also for any long term “always on” projects like a web server, having a dedicated box is generally cleaner and more secure.

The first project PC I had was my first personal PC that wasn’t “the family machine”.  When I graduated from High School, I was given a PC of my own. It was at the time a pretty “top of the line” Pentium 2 IBM with a blazing 450mhz processor.  Over the years i upgraded the hard drives and RAM and eventually the motherboard and processor.  Eventually, I found that I had a box containing all of the parts from the original machine, so I rebuilt that machine, installed Redhat Linux on it and started playing around with web server software.

During my time working IT/Engineering at my old television job, I accumulated several project machines.  When computers were upgraded, we just sort of let the old machines pile up in the back.  Sometimes these machines would go to employees if they needed a computer.  Sometimes I’d do projects at work to streamline the processes and we’d use a machine for some sort of ftp or scripted copy project.  If they were too old or just broken they’d get recycled.  I ended up with several of these machines as well.

The problem with these project machines is they are full PCs.  They need a lot of power to run, especially for something that is a very low use webserver or game server.  They also take up a lot of space.  Also, since many of the machines were used and old, they were prone to failure.  I started replacing the towers with old laptops but these have their own issues.  They take up less space and use marginally less power, but they also tend to over heat in confined spaces and if a laptop had been replaced at work, it likely had a severe issue and thus these laptops were more prone to failure and less easily repaired than the towers.

These days I’ve been phasing out the bulky old machines for Raspberry Pis.

The Pi uses way less power than a whole machine.  They are also super cheap, so buying several of them over time doesn’t really break the bank.  They aren’t super powerful, but I really don’t do anything that requires a ton of processing power, and because they are cheap, I can use several of them running single tasks to spread the load.  Frankly, they are still better than some of the towers I’ve used in the past spec wise.

So why the Pi?

There are a lot of options out in the micro PC space.  The Raspberry Pi is probably not “the best” but it’s definitely the “most supported”.  I like to learn and play around with new technology, but I’m at a point where I’m not super keen on having to fight with obscure technology.  This is pretty much the why of the Pi.  It just works.  Or at least, I can generally Google how to work it.

The Pi also runs Debian based Linux, which I am most familiar with when it comes to Linux.  Since the Pi is a full computer, it’s great for software projects.  There are GPOI pins but I’ve not really explored them yet.  I’m leaving the hardware tinkering to the Arduino for now.

Raspberry Pi Project 01 – Web Server

Raspberry-Pi-Logo So, just as a start, this isn’t a how to of any kind.  There are already plenty of tutorials on how to do whatever with the raspberry Pi.  Unless I’m pushing something unique, I don’t feel the need to provide another explanation of how to do the same thing a hundred other people have done.

I completed my first trial project on my Raspberry Pi of setting up a web server.  This is a pretty simple process that I have done dozens of times before on Ubuntu and Windows so it isn’t exactly an amazing feat.  The most amazing part is that I followed through on it instead of putting the Pi aside for “someday” like so many other projects.

The set up is really straight forward.

sudo apt-get install apache2

sudo apt-get install php

sudo apt-get install mysql

wget wordpress from wherever

sudo apt-get install vsftp

sudo mysql

create database wordpress

Futz with some permissions…

That’s it, pretty much the same as Ubuntu.  I guess this is a hot to after all.  I followed up by setting up WordPress through the WordPress interface.  I added a theme and some plug ins and created a few dummy posts.  Mostly I wanted to gage performance.  Granted, a single user web server sitting inside a firewall on a LAN is probably not the best way to gage functionality.

Everything ran fine though.  FTP uploads were a little slow, but I imagine part of that can be attributed to the memory card access speeds.  It wasn’t unbearably or unusably slow.

The main issue is that, I already run a private web server on a full blown machine inside my house.  It’s useful for playing with web dev stuff, I run a WordPress instance archiving all of my posts online together, I host a couple of other web apps for things like my webcams and Twitter analytics.  It is already running and does more than the Pi is probably capable of doing all at once.

Using my Pi as a single WordPress host is a waste of a good Pi.  It was a nice exercise to get familiar with the mechanics of the Pi, but it’s not really all that useful long term.  So I’ve wiped it out to move on to a new project.

I’ve been debating on what to use it for on my second Project.  I have been flip flopping between an XBMC media player and running Retro Pi to make it into an emulation station.  My main hang ups, the media player won’t be super useful without a media server to back it up.  I plan to buy a NAS later this year and start ripping all of my DVDs to it but that’s months off.  Retro Pi seems like the logical choice then except I have an old Netbook with a busted screen I plan to use to for building a retro arcade machine.  Still, it might be good to compare the Pi to the Netbook for the emulation station.  Also, I have more than one room so I could use two emulation boxes pretty easily.  I thought about using the Netbook guns to build a Stepmania/DDR box anyway, and it’s probably better suited to run Stepmania than the Pi is anyway.

Anyway, as usual, lots of ideas, lots of plans, maybe something fun will come out of it.

A Slice of Raspberry Pi

So, I got a new package and a new toy to play with in the mail.  Honestly I am surprised it took me this long to order myself a Raspberry Pi mini computer, When it was released, I was one of the people scrambling to try to order one immediately only to be disappointed that all of the stores that carry them were UK only.

And now I have myself a Pi.  I went ahead and ordered the suped up starter pack from Amazon instead of just the bare bones Pi and case.  I probably could have ordered the components separately for cheaper but I figured this would be much easier and would sort of guarantee compatibility.  The kid includes a breadboard and some wires and parts to let the Pi work better with the GPIO interfaces, which is something I wanted anyway.  Also it was listed as the seller in it’s category so I figure it’s couldn’t be that bad of a deal.

IMGP1931

The Kid includes the Raspberry Pi B+ board, a case and power supply, a broadboard, a breakout cable for the GPIO, some LEDs, some wires for the bread board, a set of 3 heat sinks, an 8GB Micro SD card, a USB WiFi adaprot, and an HDMI cable.  I have several project ideas in mind for the Pi and my plan is that once I set up something that I am satisfied with, I can order another basic board kit and then use the parts on a new project.

IMGP1933

I’m kind of glad I waited actually.  The Pi has evolved quite a bit over time and this model, the B+ is definitely better in a few simple ways.  It lacks the Composite video output that the original had, but has 4 USB ports instead of just 2.  The B+ also is designed so all of the ports are on two sides instead of scattered all over the place.  The basic processor and memory are essentially the same though.

IMGP1937

The case in this kit is simple but effective, the cut outs all align properly and it snaps in pretty securely.  There are also 3 heat sinks included.  It was a little tricky to figure out where the smallest heat sink went since the photos online are all for the older model.

IMGP1938

The completed set up seals up nicely.  Not only does the case have holes for the major ports, it also has slits and holes for the lesser used interfaces, like the GPIO pins and the digital display port.

IMGP1939

What surprised me the most was just how light the completed set up is.  It’s a bit thicker than my phone but probably weighs half to a forth of the weight of my phone.  I feel like this board could easily be attached to some sort of kite or glider if one were so inclined.

pibooks

I’ve already got several Raspberry Pi related books full of projects to try and i have some ideas of my own once I get the hang of how the system works.  Plus there are the projects people have done over on /r/raspberry_pi.  I also am looking forward to seeing what I can come up with to combine the Raspberry Pi and Arduino boards.

Security Cameras Part 2: The Software

So, I recently, basically ran through my plans and such for my recently acquired security cameras.  The physical cameras are only half the equation.  I only ended up making one box, and the other two I simply mounted up under the eaves in the appropriate positions.

The second step is the software.  I’m currently using three pieces of software to monitor these cameras.  First was the included myDlink service/software.  This software is most useful for accessing the cameras from outside the house.  It includes some basic notification ability but it doesn’t have an easy to way to record based on those notifications, at least not that I can tell.  The cameras themselves can push files to an FTP, but it’s sort of an all or nothing deal based on a schedule.  Running 1 shot a second creates a TON of files that are mostly useless.  The Phone app is good though (works with Windows Phone even!)

So I set out to find a better solution for capturing during motion.  I already run a private in house web server for testing, so I set out to find something that I could host there, on Ubuntu.  I came across a nice piece of software called Zoneminder.  It’s an OpenSource solution that will monitor cameras for motion and save files based on this activity.  I believe it can also record actual video though I am just doing short term recordings.  It may be a feature that I have not found, but my main issue is that I can’t bring up a view of all three cams at once.  I’m also having the usual issues with the server and IPs, internal vs external, etc.  It’s also tricky to set up.

cams

For multicam monitoring I’m using some Windows Software called IP Camera Viewer.  This simple software allows me to add IP based cameras and view them in a grid as desired.  Simple, and effective.

Security Cameras Part 1: The Hardware

Something I have been vaguely looking into over the years is a DIY solution to home security and automation.  There are several places you can pay to have this sot of thing installed and they often include a subscription for monitoring and leasing the equipment.

We’ve been having some issues lately with kids in the neighborhood knocking on doors and windows and running off late at night.  I had set up a temporary measure using my Sony Handicam on a tripod and even caught one of them once but the video was not clear enough due tot he darkness to really see anything.  Plus, filling the memory card on a daily nightly basis is not likely very good for the camera, nor is leaving the thing plugged in constantly good for the battery.

I could also use my Panasonic DV100 to capture the low light video pretty easily but it takes tapes and would only record an hour max.  Plus I don’t have an AC adaptor for it, so even if I hooked it up to a VCR or something, I’m still only looking at 2 hours max.  Not to mention wear and tear on the camera.

What I really needed was a dedicated camera designed for this sort of thing, one with night vision.  I’d tried using webcams hooked to PCs in the past but that doesn’t work in the dark either and the webcams I own are all ancient.  Plus I am tethered to a PC by a USB cable.  Amazon had a daily deal on some D-Link DCS-932L wireless cameras (which wasn’t as amazing as it seemed on paper due to Amazon’s pricing screweyness but whatever).  They were wireless, they were day/night capable and for the price I could get 2-3 of them compared to one of the other cameras I had been looking at.

IMGP0903

The cameras themselves are decent.  They were cheap, which I liked, and thought they are not super cheap in quality, they are SD only, which I was aware of but its a bit more of a letdown than I expected.  They were easy to set up, I plugged each into the router using the network cable, scanned for the IP address, and opened the GUI.  From there was was simple enough to assign IPs to each camera and connect them to the WiFi.  There is a myDlink service included for “anywhere access” but the cameras can be used independently from myDlink.  I found some software which lets me view multiple cameras at once and may set it up on a TV using an old broken Netbook I have laying around for quick access.

After ordering and receiving the cameras, I had a realization that I had neglected to consider.  These cameras are NOT outdoor cameras.  Specifically, they are not deigned to be outdoor cameras.  In my research, I knew simply placing the cameras in a window sill this would be a problem due to light reflection from the windows.  Just because I can’t see the infrared light at night doesn’t mean it wouldn’t create a massive glare on the window.

It’s still light.

I didn’t even get far enough for that to be an issue, the cameras during the day were horribly obscured by the window screens and the street lights outside, while not bright, created a massive amount of reflection from the blinds.

Oh well, at the very least, I could use them indoors, though the point was to watch the doors and driveway at night.

Still, I didn’t give up.  I did some research online and found many people had used these outside, for at least months and in one case years.  The main concern was condensation and humidity, and to a lesser extent, temperature.  One video even put the camera out on a table in the pouring rain for an hour with no ill effects.

So I set out to build a weather resistant enclosure for the cameras.  I’ve used plastic electrical boxes in the past for other projects and this one was pretty much just drilling a few holes in some plastic.  The boxes I found at Lowes came in 4×4 and 6×6 sizes.  I had my wife measure the camera and she said it was not quite 4 inches tall minus the base, so I opted for the 6×6 box.  The boxes themselves are pretty thick and I wasn’t sure the inner cavity was actually 4″x4″ on the smaller boxes.  Plus going with 6×6 gives the cameras room to breathe a bit, since it is still an electronic device and will generate some heat.  My main irritation wads that the 6×6 boxes were almost twice the cost of the 4×4 option.

I started by measuring out the center along one axis of the box lid, then measuring out the placement of the camera’s circular lens ring on the other axis.  I then found the center point of the circular areas and marked the counterpoint of the hold I was going to drill.  I measure the camera camera ring at 2″ in diameter and used a 2″ drill bit put apparently came up off somewhere because the hole was about an eigth of an inch larger all around.  Slightly annoying because I wanted a tight fit but it was workable and I can always seal it later with some caulking or even just some foam weather sealing that I have laying around.

Next I drilled holes in the bottom of the box to match the screw hole mounts on the bottom of the DSC-932L camera mount.  This size was dependant on the bolts I had handy that would fix in the screw holes.  This would allow the camera to be bolted into place inside the box.  Finally, I needed to get the power cord through.  The largest normal drill bit I had was not quite large enough to make a hole for the power cord to fit through but I was able to ream out the hold enough to get the plug through.  The benefit of this tight push was that the hole would be smaller and easier to seal up.

IMGP0902

So after mounting the camera with bolts and pushing the power through and assembling the cover around the lens, I hade a self contained weather sealed box (the electrical box has a nice rubber seal between the lid and box).   I am not real sure yet on the best way to mount the box but I placed it outside last night on a plant stand and let it run through a rain storm.  Worked out fine and the video from outside the window worked fine.

This project definitely isn’t done but it’s off to a good start.  Next will be finding an effective way to mount the boxes under the soffits, and, more important, providing power.  The cameras are wireless to the network but they still plug in.  I had some ideas about running extension cords through the soffits to the garage but I’m thinking it will be better to just install some outlets in the attic at the appropriate points.  I have a motion activated light I took off of our rental property after the fire that I plan to install on the front door, so the front door cam may just get a hook up right there on the light, since the motion light will need to be on all the time anyway.

The project is working out pretty well though despite a few hiccups.