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.

Weekend Project – Picket Fence Shelf

Just wanted to show off a little recently completed wood project.  My brother ended up with a huge pile of extra fence pickets and I put some of them to good use making some shelf units for my daughter.

IMGP0990

The process was pretty straight forward, each shelf consists of 11 pickets and 3-4 30″ boards.  The board length is variable of course which may alter the number of pickets needed.

First, I did a rough sand job of each picket, rough because I wanted to remove the worst of the rough bits but leave some of the overall “rustic” roughness of the surface.  The pickets were also trimmed off by 1″ incrementing lengths (1″, 2″, 3″, etc) so they would stair step across the back.  The boards for the shelves were also cut from an 8 foot 1×10″ board.

At this point, everything was painted with several coats of white paint.

Assembly is a bit tricky but by the third shelf I had a pretty good method down.  The side pieces get marked for where the shelves should fall (variable intervals depending on needs).  Then the side shelves are screwed onto the ends of each shelf in the appropriate places (I just screwed right through into the ends of the shelves, careful not to split things).  Two screws each picket, each shelf point.

Then I measured out from the edges on the backside to line up the longest center picket in the middle, this is then screwed down with a 1/4″ off set from the bottom from the sides.  This will leave a small gap along the bottom along the back.  The purpose is to make the unit more stable so it will only hit the floor on the side pickets.  Getting 4 side pieces to sit flat as legs is a lot easier than getting 11 pickets to line up flat on the ground (which would cause the shelf to wobble).

Next the two shortest back pickets are attached along the edges of the back.  The remaining pickets get attached last and I found it was easy enough to just eyeball the spacing.

I also added some simple boxes to the bases of two of the shelves to give some added height (as pictured above).  This part is optional.

Security Phase 2 – Doors and Windows (Planning)

I just wanted to start off by saying, this isn’t a how to at all, it’s more some general ideas I’ve been looking over for how to add door and window security to my recently set up video monitoring system.  Basically, I want a log of when and if the doors and windows are opened and closed.  I’d prefer not to run a bunch of wires, so wireless sensors are in order.

What I ultimately want is for an indicator light on a webpage to change based on the status of the door or window, a timestamp log to be created and possibly for some sort of email or text alert to occur.  ULTIMATELY I may even use this whole project as an excuse to finally develop my Phone app skills and build an app that I can view it all on, but that’s farther down the road.  A basic web page is fine for now, and it’s something I can manage.

My worry with wireless sensors was that I’d have to constantly change the batteries.  Until I realized that it would be trivial to design the sensor so that it only transmits when the window is open, and while I am not building my own sensors (I probably could) I imagine the makers of such sensors realize that you could save a ton of battery life by designing the sensors to only work when open.  I did a bit of searching on Amazon and found a6 pack of sensors for less than ten dollars.  It appears that each sensor has it’s own receiver/indicator which emits an audible tone.

This is actually probably alright for my needs.

While I am not an Electrical Engineer, I am familiar with basic circuit flow and basic electronics.  I don’t have any of these sensors yet but I can make some basic assumptions based on what I know.   When the window/door is opened, some trigger is closed and the sensor starts transmitting some sort of radio signal.  The fob thing which is always listening will receive the signal and activate some sort of internal speaker. 

There are a couple of issues that need to be solved here.  One, while the sensors hopefully are designed to conserve battery power, the FOBs are probably not.  I also want the signal to go to a computer and not sound a mostly useless audible alarm.  The power issue isn’t a huge issue.  With the right transformer brick providing the proper voltage, it wouldn’t be hard to rewire the contacts to allow for the units to be plugged into the wall, all at once, off of one power supply.  They look to be small enough that they could be mounted inside an electrical box in a small array and wired for power.

A similar method can be used to transform the speaker signal into a trigger for some sort of simple IO board.  To activate the speaker, some sort of voltage is applied to the speaker, the speaker can easily be removed and the contact points that would previously have fed the speaker could be wired to am IO board.  When the voltage is supplied to the "speaker" it will instead be read by the IO board, triggering a signal that "the Window/Door is open."

The main puzzle I have right now is, what would work best for the IO board.  I see two options here, and both would function differently, and I may even require both.  I could go with an Arduino board or a Raspberry Pi.  Both of these options seem to have advantages and disadvantages, and there may even be a third option which corrects the disadvantages.

arduino

Let’s look at the Arduino.  The Arduino is ideal for dealing with the IO board.  It is, by design, meant to work with this sort of "hands on" electronics systems.  It even has build in contacts for working with two wire IO interfaces.  I don’t know anything about Process, the programming language of the Arduino, but I’ve been meaning to learn and I am capable of learning it.  The problem is on the output.  Arduino is not designed to work with PCs in any simple way.  From some quick research online, the Arduino would require a serial interface and likely special software running on the server to poll the Arduino at set intervals.  Which brings up another issue.  As near as I can tell, the Arduino is a "pull" interface, meaning the server would have to pull the status from the Arduino, as opposed to "push" where the Arduino would push the data to the server as it changes.

Raspberry_Pi_Photo

So there is also the Raspberry Pi.  The Raspberry Pi is a computer itself, which makes interfacing with the server simple and easy.  It runs a simplified OS but connecting the Pi to the network is simple and telling it to push even a text file status update to the server via FTP or some similar network protocol is trivial.  the issue comes in the need to read the sensors.  I’m not entirely sure the Raspberry Pi is even capable of reading an analogue IO interface right out of the box.  Some searching suggests it is possible through an additional interface board of some sort but not right out of the box.  Looks like there are a handful of GPIO points build into the PI.  The PI also feels like much more than is really needed for this simple application.

Its kind of a tricky decision, I’ve been wanting to play around with both the Pi and the Arduino so I may just pick up one of each and see what works.  Both are around the same price and the whole system in the end will end up costing around $50-$75, which is almost nothing.  The final step once the sensor data lands on the server is updating the web page but I already am familiar enough with building webpages and simple polling scripts that this step is the easy part.  Whatever I end up going with I’ll certainly document the results in the future.

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.