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.

Identity, Privacy, Anonymity

identity I had a short conversation recently over on Reddit that got me thinking a bit about the idea of online identity and, by extension, the ideas behind privacy, and anonymity online.  Privacy is a hot button issue in general lately and there has also been a lot of people causing some fuss over the idea of anonymity online. 

It’s ridiculously easy to be anonymous online.  Ok, let’s rephrase that, it’s ridiculously easy to be mostly anonymous online.  You want to be mostly anonymous, it’s trivial to make "fake" email accounts or identities.  You can even be pseudo anonymous by using a pseudonym.  If you were doing something malicious, it wouldn’t be hard to track you down from a simple pseudonym, especially if some large corporation or government wanted to track you.  Chances are you’re pulling cookies around in your browsing, and you’re connection will have a unique, logged IP address complete with time stamps etc. 

Being actually anonymous is trickier but still pretty trivial, spoofed IPs, TOR browsing, using open WiFi access points, especially public ones, in areas where there are no cameras, etc.  I’m not really here to discuss true anonymity online though, more the idea of pseudo anonymity.  This is the sort of anonymity that many more casual users of the internet greatly dislike.  It certainly has it’s good sides and it’s bad sides.

The complaints often come because of "Trolls" who use the anonymity granted by the internet as a means to be rude or mean.  The problem is that the term troll is often greatly misused or misappropriated.  I once wrote a pretty long essay back on usenet about what a troll is but the short version comes down to a few things.  Trolls and straight bullies are not the same.  Trolls and straight assholes are not the same thing.  Being an actual troll does require some effort, just going and telling someone they are "a stupid fag" on an anonymous board doesn’t make you a troll, it mostly just makes you an idiot.  The real point of trolling someone is to speak contradictory to what is being presented, not necessarily to prove an alternate point of view but to disprove or discredit the original view being presented.  There is a point when trolling turns into idiocy and harassment.

It’s simple, people don’t like being disagreed with or having their viewpoint challenged.  If that person can’t actually defend their viewpoint, they may get called out on it, and they call the person calling them out a troll, a "coward" hiding behind anonymity. 

"You wouldn’t say that to my face in person, why do you do it online?"

This is a tricky question on many levels and isn’t really an exact parallel.  If you put masks on everyone involved to make them "faceless", put them in a room, and had the originator read their originating comment out loud, would people still say "mean things"?  What if just the trolls had masks?  Also, a lot of people do say dumb asshole comments in face to face situations.

However, yes, there is something freeing and liberating about anonymity or even pseudo anonymity.  I’m sure there is some actual psychology behind this concept.  It’s basically the same concept of "dancing naked when home alone".  People act differently when they think no one is watching.  It’s human nature.  We pick our noses, we scratch out but cracks, we dance naked, we make rude comments online.  The main difference is that picking your nose doesn’t really hurt anyone else.  Does a rude comment really hurt anyone when everyone is anonymous and everyone has the option to make rude comments? 

"You wouldn’t say that to my face in person?"  Maybe they would.  But what if you could punch back.

So let’s take a site like 4chan (the website not the "1337 hax0r duud"), where everyone is anonymous.  Yeah, it can fall into a cesspool of filth but it also can lead to a lot of good discussion.  Much of the worst is confined to /b/, and 4chan is much more than just /b/.  Even discussion of places like /v/ (Video Games) and /toy/ (Toys) can be more interesting when people feel more free to dislike what they dislike and speak their minds.  You also don’t have to deal with people trying to be some sort of crazy internet celebrity in their area of interest.  Identity is frowned upon in general, so you just get pure discussion.  No one trying to be pretentious about who they are and what they want people to think of them as, just pure discussion.

Does it lead to arguments and shit slinging?  Of course it does.  Does it lead to idiotic arguments that make no sense?  Yep.  It also leads to acceptance.  Acceptance of ideas, because maybe you actually lose an argument, but because you aren’t saddled with the pride of your identity, you are free to accept defeat, even if it just means quitting the argument in disgust.

Then there is the idea of Psudo anonymity.  Your online handle or username if you will.  You still end up with some level of reputation but it’s one step removed from your private life and personal identity.  Its also pretty easy to manage multiple online online "personas".  Chances are if you are managing multiple identities on any one website that website could easily cross connect them to each other but for basic outward facing use, it can serve a purpose.

Take Reddit.  While similar in nature to 4chan, since it’s full of user generated content that lives and dies by how much support it gets, Reddit has an identity system.  Reddit also has an archive, everything on 4chan drops off eventually sometimes in minutes, sometimes in days, but it eventually dies.  Reddit has an archive, and an identity and everything you post is easily attributed to you.  More importantly, Reddit has the "Karma system" where users can up and downvote good and bad posts.  Granted that a lot of people know that Karma is "useless fake internet points" and there are even people who try to get negative karma instead of positive karma, but it does help by giving a tangible indicator to "how good" a person is.  It’s not perfect of course, some people may be good at things that aren’t relevant.  Someone who posts to Gonewild and has 4000 karma as a result isn’t necessarily going to mean anything when it comes to political discussion. 

Hence, "meaningless fake internet points."

Then there is Facebook.  Facebook is where you connect to friends and family.  People you will know for long periods of time, possibly your entire life.  Many of these people will know you better than you know yourself.  They will know when you’re being fake and call you out when you’re being an idiot.  These are most likely the people you want to know and want to be judged by.  There is also a lot of push for having a "real identity" on Facebook.

Facebook is a place where people go to "be real." 

All of these places have elements of each other, and it’s a very tiny sampling of the endless array of websites on the internet.  Each exemplifies a major component of online identity.  A board like  4chan is all about being anonymous, but you can choose to fill in that name field, and there is even a system in place to keep your identity verified.  Reddit gives you a name and points, encouraging you to behave for the most part, but it’s not required and can one can easily start over if there is a major screw up.  Sites like Facebook, want you to be "the real you" but really, nothing is stopping anyone from making multiple Facebook profiles and fake identities.  Hell I have a Facebook Page for my cat that I rarely post to.

The point is, the closer you get to your true identity, the less publicly open you tend to be, at least about your real feelings.  There is a fear of being judged or shamed.  A fear of upsetting the lifetime friends and family we have.  Anonymity still has a place though.  It’s like a confessional, or the comment drop box.  It’s a way to voice opinion without feat of retaliation.  There are often many reasons to fear retaliation.  Assholishness and trolling aside, opinions are often formed that are negative towards people with power.  People with power often have very strong methods of retaliation at their disposal.  There needs to be a means for people to speak out against real injustices.  The side effect is that sometimes you end up with "trolls" and assholes.

Some people just need to accept that sometimes a difference of opinion is a good thing.

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.