Python IO on rPi

My next ‘real’ project involves implementing a web interface to control some of the things around swan tron global HQ, the half of the garage I reserved for my lab. I’ve been a huge fan of the Raspberry Pi since the mission was announced. Linux and IO…you have my attention. Add in the $35 price tag and my penchant for destroying hardware…huge fan is correct.

Before I start planning my real project, I need to figure out how this differs from the microcontrollers I’ve used in the past to deal with similar implementations. I know the CPU is going to show itself, but not to what extent. Time to start poking around.

I decided to horse around and knock out a few birds with one stone…python library, digital out, and basic pin function. Oh, and LEDs. Everyone loves LEDs.

the 80s called, they want their printer cable back
cobbler and bread

Prior to this effort, I have mainly explored the rPi via x. I’ve spent a decent amount of time inspecting the file structure (Debian, no surprises) and the xwin UI. It is no speed demon, but it does the trick. I have the wireless adapter configured and set to auto-start, which was most of the battle. It basically performs as advertised, which on paper is very awesome for the price.

My general setup for this was very simple. I bought a cobbler set from Adafruit, which acts simply to pull the IO pins out to a breadboard. Two LEDs, two resisters. A few jumpers. Very simple.

I booted the device, and used aptitude to update and snag the rPi GPIO library.
sudo apt-get update
sudo apt-get install python-rpi.gpio
That does the heavy lifting with the python implementation…sample code is available on the main python site. The update was I used vim to create a dirty python script…unworthy of a repository, but worth a pic:

fugly code
no comments, no worries

The digital outs worked as anticipated. Timing was a bit odd…I ended up playing around a bit with some pauses in order to tune the blinks as I wanted. It looks like coordinating pin outs might be tricky for more complex operations, but at least the library and hardware is up and running.

Don’t take my word for it:

The next steps will be interesting. Figuring out how to ssh into the box in order to run a script of this magnitude will be next, followed by profiling the voltage on the pinout. It should be able to throw my 5v relay with a little tweaking…if not I’ll figure out PWM and tackle the switching mechanically. Fun stuff to come…happy to be playing with the rPi finally. Stay tuned.

Occidental Distro Setup

I’ve wanted to play around with Adafruit’s Occidental distro since it was announced. The whole gist of the release is that it better caters to the hack-y types…they have taken Wheezy and built in some utilities. Especially cool is Bonjour, which *should* allow ssh access from my other networked machines. Still getting to that point, but I have installed the thing for experimentation.

Thus far I have been poking around…my small assistant did some stress testing…

raspberry pie occidental distro
keyboard smacking

I have some battery packs in the mail, and I need to configure my WiFi dongle. The idea is to let the machine run headless, and see what I can stand up with Python. I need to play around with the pinouts a bit and come up with some ideas. I could bring Clocky back from the dead…we’ll see what shakes out.

Android IP Webcam Demo

Poking around on the Android Market for an app to control my Foscam IP Webcams, I stumbled across a cool app concept. Long story short, someone wrote some code to serve the live camera feed…effectively turning an android device into an IP cam.

android demo ip webcam
web cam-y

The app is free on the Market…just search for IP Webcam and it will pop up. Here it is in operation, serving from my Droid 2 for viewing on my Linux machine…

This would pair nicely with my IOIO project, provided I can bring it back from the grave. I could mount the phone itself on the payload, giving this sucker on-board video. A second device (Galaxy…) could provide the board control, and I could implement a web view into my app. Might be on to something here…stay tuned.

Spotify on Linux

Hey nerds. Guess what? Spotify on Linux.

Super easy too…fire up a terminal [ctrl-alt-t]

Step one:
cd /etc/apt
Step two:
sudo vim sources.list
Step three:
add “deb http://repository.spotify.com stable non-free” to the file

spotify for linux
sudo vim

Step four:
sudo apt-get update

spotify linux ubuntu
_{_n_/_Y_}_Y

Step five:
sudo apt-get install spotify-client-qt

spotify on ubuntu
can I kick it

That is that. It is not a supported version, but I doubt anyone installing via aptitude will really care about that item.

Side thought: How sad is it that my favorite album came out in 1993? Old balls.

Virtually Awesome

You may be wondering how I could one-up my work setup. Probably not, but play along.

We are too .NET-y for me to nuke Windows, but Oracle-y enough to get carte blanch on a whole bunch of new stuff.

Item one: VM Virtual Box Manager

virtually awesome
virtually.

I have an Ubuntu box rolling on the far right and an Oracle Linux box dead center. DropBox setup on the base machine and virtuals, for quick file mashing…diffing…command line python…grepping, etc. Good stuff.

The only thing that could be more virtually awesome would be a fourth monitor running Arch Linux. Virtually unbeatable.

Android SDK / Eclipse / Ubuntu

I updated to Ubuntu Oneiric Ocelot last week. For some reason, the automatic upgrade process botched pulling over my Android Development Tools (ADT) components. Chalk this one up with the strange camera issue I am seeing, as two votes for bailing on a fixed release cycle. Canonical has pushed out two consecutive iffy builds…but I digress.

It had been a while since I had set my Android development environment up. I had to start from scratch, so figured I would spell out the process.

Note the lack of “Android *” from the list of installed components:

eclipse ubuntu android sdk
...no sign

I’m starting from the point of having Eclipse installed. That part is straight forward…I snagged it off of the Ubuntu Market, but you an do it with Aptitude or however you like. Same goes for the JRE and JDK, the Java Runtime Environment and Java Development Kit. Snag those from the Market, Sun’s site, or apt – get…verify you have the correct version by running “java -version” from the command line. Mine is currently:

swantron@Dell15:~$ java -version
java version “1.6.0_23”
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre10-0ubuntu5)
OpenJDK Server VM (build 20.0-b11, mixed mode)

The Android SDK is the next component to snag. It has two pieces: Standard SDK (starter package) and SDK components. The later is where you can grab pieces to test Galaxy Tabs…stuff like that. The specifics are located there. You first need to download the starter package from d.android.com/sdk and run the UI. There you can pick and choose the pieces you want to implement, manage emulators, etc.

The last piece is the actual Eclipse plug-in. It is simple to implement. Navigate to Help . Install New Software, and feed through the process until you are asked for a site location. Said site is dl-ssl.google.com/android/eclipse

A restart should have Eclipse up and running. Give a shout if it doesn’t…after doing this a few times, I am becoming somewhat of an expert.

Ubuntu Update Day

The Dell Mini 9 always draws short straw. The little guy once again gets to play the part of guinea pig, and be the first to upgrade to the new version of Ubuntu.

ubuntu upgrade day
+1 Oneiric

V. 10.11 a.k.a. Oneiric Ocelot

We’ll see if they sharpened Unity up a bit. Preliminary reviews are pointing at a good release. Expect my review before long.

FWIW, ‘oneiric’ is a mouthy way to say dreamy. I don’t care for the word, and neither does my spell checker.

Ubuntu Update Day

The Dell Mini 9 always draws short straw. The little guy once again gets to play the part of guinea pig, and be the first to upgrade to the new version of Ubuntu.

ubuntu upgrade day
+1 Oneiric

V. 10.11 a.k.a. Oneiric Ocelot

We’ll see if they sharpened Unity up a bit. Preliminary reviews are pointing at a good release. Expect my review before long.

FWIW, ‘oneiric’ is a mouthy way to say dreamy. I don’t care for the word, and neither does my spell checker.

Makeshift Linux Heads-Up Display

Per my last post, I began upgrading my Dell Mini 9 last night…from Ubuntu 10.10 to 11.04. Well, at some point, it tossed a fit about not being able to snag a package, and hung on a dialogue box all night. No worries…I’ll finish this install on the way to work.

ubuntu linux netbook on my silverado dashboard
check the speedometer...

Who said netbooks are passe? Looks like that guy was designed to ride on the dash of a Silverado if you ask me.

For the record, I was not doing 110 MPH by the MSU campus. I have an issue with my speedometer. I was doing 90 MPH, tops.

My install was a success for the record. I will see if all functions are fully functional soon, and put together a post.

HTML to Python to Arduino to LCD

Last week found me standing tall upon my shell script soapbox, shouting command line praises to all who would listen.

Thou ought direct thine output aftways, to-wards thine USB port of thee. And that is well and righteous.

Well, that still is the case. My latest project has made it glaringly obvious that sometimes a little Python script will render a whole bunch of shell scripting moot. Namely, parsing HTML. Let’s see a picture…

outdoor hacking
bad lab mobile

Lunch hour project: parse the comments from swantron.com; feed said comments to an LCD screen.

I was horsing around with wget from a CLI a few days ago. I found myself trying to smash through the resultant file via pure regular expressions…which is incredibly clumsy. Well, as luck would have it, my go-to after my main go-to is Python, and this type of thing has been issue enough to warrant a library. BeautifulSoup. It acts to parse the HTML info into items, that can be smashed around as I see(med) fit.

My setup was simple: py script to snag my comments and write serial, Arduino sketch to drive a LCD and read/write serial. And a source of shade. And a WiFi signal to snag.

mobile mobile
bad lab mobile-mobile

Check, check, check, etc. Video time:

Pretty slick…hit the fold for the code, as promised, and a summary.
Continue reading “HTML to Python to Arduino to LCD”