Thursday, September 13, 2012

Day 0

Someone told me IRL that I was putting the cart before the horse, that I should really have at least one or two posts that explain how to get started with the raspberry pi.

So, here is what you will need to do if you are interested in getting one, but don't know where to start:

1. Buy a raspberry pi. You can do this online, there are a few distributors. Go to raspberry.org to figure out which one to use, based on your country. Or maybe your local hackerspace is doing group buys on them, check them out.
2. Wait a while until you get one delivered to your door.

Seriously, it will take a while, so in the meantime, start shopping or digging around for the other stuff you will need. At a minimum, you will need:

1. A 5v micro usb power supply
2. A 4GB SD CARD
3. A USB keyboard
4. An old tv or color monitor with composite (RCA) in.

It will make things nicer if you also get:
5. A USB mouse
6. A USB hub
7. A wifi dongle
8. A case
9. A USB drive
10. ...

Instead of 4, an HDMI monitor might be a better option, particularly if the Raspberry Pi will be used as a full time desktop computer. The Pi doesn't support VGA directly, but an active adapter can be bought (expensive).

Yes, the $35 computer can cost twice that or more depending on the options.

So, today, we will address point #1, the power supply. Physically, the plug needs to be a micro USB and electrically, it needs to deliver 5V at 700 mA or more (0.7 A). Look around, you probably have a cell phone power supply that will work.

I've used Blackberry Power supplies, quite appropriate for a Raspberry...

But another option I am quite fond of is the Duracell 3 in 1 charger. I've not seen anybody mentioning it anywhere, but i've been using a few for months now and they work well.


It has adapters for iPhone and iPad, motorola, kindle, nook, samsung, lg, blackberry etc.


It is 3 in 1 because you can use it from the wall socket, from 12V (in a car or a solar kit) or from a USB port, including a battery pack (that part is not included). It puts out 4.75V to 5.25V at around 1 A. Perfect match for the RPi.



The tip to use is the micro USB.




So, once everything is connected together, you'll get this:


It sells online for about $13 to $20 but in local discount retail stores (in the USA) I've found them for about $12, so it pays to shop around. If you know of an equivalent product in your neck of the woods, drop us a note in a comment!

Next on our list will be the SD card...

Tuesday, September 11, 2012

Sidekick

So, Batman has Robin, Sherlock Holmes has Dr John Watson, Sheriff Andy Taylor has Deputy Barney Fife... Well, you get the idea: All heroes have a sidekick (if not, they are missing out).

You need a sidekick

Or at least, your desktop does.

If your desktop is a Raspberry Pi, then you already know the life of a sidekick well, or at least you are learning it. This article is not really for you, although it might come in handy later. So, for all you Raspberry Pi owners who do everything on the Raspberry Pi, stay tuned to this blog for a future post: The Sidekick's Sidekick.

Unix, Linux or Mac Desktop

This will be smooth sailing. Open a terminal and type:
 $ ssh -X pi@raspberrypi  
 pi@raspberrypi's password:   
 Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l  
 The programs included with the Debian GNU/Linux system are free software;  
 the exact distribution terms for each program are described in the  
 individual files in /usr/share/doc/*/copyright.  
 Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent  
 permitted by applicable law.  
 Type 'startx' to launch a graphical session  
 Last login: Tue Sep 11 15:32:33 2012 from v480-sunray  
 pi@raspberrypi ~ $   
The first time you will be asked to accept the host key, say yes. Enter your password when prompted. If you entered the correct password, you are in.

Windows (XP, 7, ...)

Ok, this is a little more involved.
  1. Download Putty
  2. Enter the following information in the configuration:
  • Hostname: raspberrypi
  • go to the ssh tab and click X11 forwarding
  • Entere for Saved Session: raspberrypi
  • click Save

I'm not going to go through all the details here. Simply to say that you need to go to the ssh tab and click X11 forwarding download Xming server which will add an X server to Windows. You then need to start the Xming server from the start menu, then open the session in Putty. For more detail, go here
  • Double click on raspberrypi (or select and click open)
You will be asked to accept the host key, say yes. Enter your userid (pi) and password when prompted. If you entered the correct password, you are in.
With that setup however, you only get a fraction of the functionality of what we did for Unix, Linux or Mac.

What are we doing again?

You can now run any console application directly in that window, but even more interesting is the fact that you can run a graphical application on your Raspberry Pi, but the graphical display itself will be on your desktop.

Look, Ma, no VNC! For example, you want to run the midori browser. In the ssh window, at the prompt, type: midori
 $ pi@raspberrypi ~ $ midori
And you should get:
Or perhaps you want to write some Python code. After all, this is a Python centric blog...
 $ pi@raspberrypi ~ $ idle
And you should get:
Now, remember, although the idle window is on my desktop, when I type import web, it is importing a library on the Raspberry Pi, and not from my desktop. By default, web.py is not installed by default.

To install:

pi@raspberrypi ~/Desktop $ sudo easy_install web.py
Searching for web.py
Best match: web.py 0.37
Processing web.py-0.37-py2.7.egg
web.py 0.37 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg
Processing dependencies for web.py
Finished processing dependencies for web.py

In the above example, it actually didn't download the library, because I had installed it already. In fact, one of the first thing I did. Web.py is like duct tape for web applications. Or Web services. Or template driven apps. Or scripts that need database access. I could go on. Although a web framework, each module can be used individually, or can be replaced, or used alongside similar modules. On the screenshot, I did a dir(web) to show what modules are available. If there is some interest, I'll do a tutorial on using web.py, just let me know in the comments.

Concluding on this way of working, I could be editing python code in idle, while viewing the result of my web application in a web browser (either locally through midori or remotely using my desktop's browser). But that, is just touching the tip of the iceberg. There will be more to come in the coming weeks.

[Edit:]
Part 2


Tuesday, September 4, 2012

Raspberry Pi: From Kindergartners to MadScientists

Raspberry Pi: From Kindergartners to MadScientists

That is the title of the talk I will be giving on october 21st, at 4pm, part of the program for PyCarolinas 2012, the first Python conference held in the carolinas ( the states of North Carolina and South Carolina on the southern east coast of the United States, for our international readers).

When:
ical 
October 20th-21st

Kerr Hall
UNC Eshelman School of Pharmacy
Chapel Hill, NC

What:
  PyCarolinas' website



So what is the talk about?

  • A quick background on the Raspberry Pi
  • How it can be used in education
  • Comparison with a typical desktop
  • The mad scientist bit (interfacing with hardware)
As far as Python is concerned, there will be setup, demo, explanations of libraries etc and the last part will cover GPIO libraries, some Web.py and other cool bits. Be there or be square.

Logo turtle graphics

I remember fondly going to the university with my dad, as a toddler first, and as a young boy later. Pretty quickly, I was able to gain access to the computer lab, where they had the Apple ][. Later they would get the ][+, //e etc.

Anyway, there, I could request a disk with a wonderful program called Logo turtle graphics. That was  my first real exposure to programming. You controlled a little triangle (the turtle), pen up / down to draw or move without drawing, back, forward, left, right (rotations), etc. There was even the possibility of loops, functions etc. You can learn more about Logo here Logo Foundation

The Raspberry Pi Raspbian operating system comes with Python, and as such, with Turtle.

In logo, I remember writing something like this:

repeat 10 [ circle 50 forward 60 right 36 ]

With python, the last 4 lines are equivalent:

$ python
>>> from turtle import *
>>> up()
>>> back(200)
>>> left(90)
>>> down()

>>>
>>> for x in range(10):
...    circle(50)
...    forward(60)
...    right(36)
...
>>>

The result?

As a side note, I took the snapshot from my OpenIndiana desktop. I accessed the Raspberry Pi using the command:

ssh -X pi@rasp01

This allows a tuneling of X Windows, so when I start python, import turtle and start drawing, it is drawing using tkinter using the OpenIndiana desktop X server to render the above window.


In conclusion

I do owe my > 30 years in programming and the mastering of various languages such as assembler, Basic, C, C++, Pascal, Java, Python, etc to my first exposure to programming at a young age. It is crucial that the youth of today similarly get exposed to more than how to use Office or Photoshop. They need to learn how to program and how to tinker. And the Raspberry Pi provides that ticket into that world.

Sunday, August 19, 2012

Wheezy Uptime

So, my raspberry pi was upgraded to a new OS at the beginning of the month:

Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Type 'startx' to launch a graphical session Last login: Tue Jul 31 22:03:41 2012 from sunray-v480

The OS is Raspbian, a debian wheezy linux distribution for arm processors, with hardware floating point support.

It is such a low power device, it can be on at all time, and consumes less power than my workstation when powered off (which draws 4 watts due to power supply minimum draw to support LAN wakeup). Great for a test webserver, or a monitor (for an alarm system, for motion activated cameras and the like), for kiosks, information displays, for streaming audio and / or video and the list goes on. And it is stable:
  pi@raspberrypi ~ $ uptime 12:33:22 up 18 days, 22:45, 1 user, load average: 0.00, 0.01, 0.05

In an hour and 15 minutes it will have been up 19 days. Not bad considering I installed the OS 19 days ago, and the Pis are still hard to come by...

Friday, August 17, 2012

And the back

Not much to see but the sd card. It is 16gb, so there is plenty of space for installing software. Right now it is running web.py apps

What it looks like

The naked raspberry pi board as it came. I just added the sd card.