Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science

Introduction

The Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools. The Raspberry Pi is manufactured in two board configurations through licensed manufacturing deals with Newark element (Premier Farnell), RS Components and Egoman. These companies sell the Raspberry Pi online. Egoman produces a version for distribution solely in China and Taiwan, which can be distinguished from other Pis by their red coloring and lack of FCC/CE marks. The hardware is the same across all manufacturers. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded to 512 MB. It does not include a built-in hard disk or solid-state drive, but uses an SD card for booting and persistent storage. The Foundation provides Debian and Arch Linux ARM distributions for download. Tools are available for Python as the main programming language, with support for BBC BASIC (via the RISC OS image or the Brandy Basic clone for Linux), C, Java and Perl.

Some Useful Raspberry-Pi References

Some useful tips & tricks on working with Pi:

How can I add and share printer connected to Raspberry Pi in my local network:

Unlike a typical Windows machine, the little Raspberry Pi running Rasbian doesn’t exactly come with plug’n-play printer support. We need to install and configure printer support manually. To do so, open a terminal window, then insert:

sudo apt-get install cups
sudo usermod -a -G lpadmin pi
sudo nano /etc/cups/cupsd.conf

in the cupsd.conf look for line #Listen localhost:631 and change it to Port 631 to have access to your Pi printer server from your local network rather than just Pi itself. Now in the terminal type:

service cups restart

You can now access to the Pi’s printer settings from: http://raspberry-pi-ip:631

Adding a Printer to CUPS

When you first navigate to http://raspberry-pi-ip:631, you’ll see the default CUPS homepage. The section we are interested in is the Administration tab. Click on it now.

Within the Administration panel, click add printer. If you receive a warning about the site’s security certificate, go ahead and click proceed anyway to ignore it. You’ll be prompted to enter a username and password.

Go ahead and enter the username and password of the account you added to the “lpadmin” group earlier in the tutorial and click “Log In”.

After logging in, you’ll be presented with a list of discovered printers (both local and networked). Select the printer you wish to add to the system:

After selecting the printer, you’ll be offered an opportunity to edit the name, description, and location of the printer, as well as enable network sharing. Since our printer is already a network printer, we left “Share This Printer” unchecked:

After editing the printer name and adding a location, you’ll be prompted to select the specific driver you want to use for your printer. Despite the fact that it automatically discovered the printer and the printer name, CUPS makes no attempt to pick the right driver for you. Scroll until you see a model number that matches yours. Alternatively, if you have a PPD file for the printer that you have downloaded from the manufacturer, you can load that with the “Choose File” button.

Login to your Raspberry Pi using your public key instead of password authentication:

The first step is to ensure that you have a public private key-pair installed on your local machine. Most developers will already have this but in linux or mac you can normally generate a new pair using:

ssh-keygen -t rsa -C "your_email@youremail.com"

I won’t cover creating these in any detail as there are plenty of guides available. Github’s guides cover this as a side effect of setting up git here and an issues helper here.

Now copy your public key to ~/.ssh/authorized_keys in your Raspberry Pi machine. Now we should be able to login using:

ssh pi@pi-ip-address

This time we shouldn’t be asked for a password it should use the key instead!

How to configure Raspberry Pi to have an static IP address:

It is usually more convenient to setup Raspberry Pi to request an static IP address on your network. This way, you can easily access to the Pi without the need to use a IP scanner tool.

To make your Pi requesting an static IP, open a terminal window and follow:

sudo nano /etc/network/interfaces

Remove the line that reads (iface eth0 inet dhcp) and add the following:

iface eth0 inet static
address raspberry-pi ip (i.e. 192.168.1.2)
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

But how did I come up with these numbers. To get the numbers boot into Raspian and log in. First, we need to list the network interface we currently have available:

cat /etc/network/interfaces

The line iface eth0 inet dhcp implies that we’re currently getting out IP address via DHCP, meaning it’s being dynamically registered by the router. This is what we want to change! To gather the information we need, first of all we need to grab some information from our router and Pi. There’s a couple of command we need to run to get this info. The first commend to run is ifconfig. This reveals your router information, the bit you want is after eth0 (the ethernet connection)

eth0  Link encap:Ethernet  HWaddr b8:27:eb:b3:fc:2c
      inet addr:192.168.1.81  Bcast:192.168.1.255  Mask:255.255.255.0

Write down the following information:

  • inet addr – 192.168.1.81 (Pi’s Current IP Address)
  • Bcast – 192.168.1.255 (The Broadcast IP Range)
  • Mask – 255.255.255.0 (Subnet Mask Address)

We need a little more information before we proceed. Use the command netstat -nr. From the output of this commend with need

  • Gateway Address – 192.168.1.254
  • Destination Address – 192.168.1.0

That’s pretty much it! Now reboot and check your changes.

Changing the default username and password or edit local time setting

The simplest way to change the password of the default user in Raspbian is to make use of the raspi-config administration menu. This will need to be run as root. To achieve this we can log on as the user pi with the password of raspberry. These are the default user and password. To run raspi-config with root permissions, we preface the command with sudo:

sudo raspi-config

Now browse through the options and change password or time settings.

Using Raspberry Pi as a BitTorrent client

Although there are several BitTorrent clients available for Pi, here we are using Transmission. Open a new terminal and follow:

sudo apt-get install transmission-daemon.
mkdir /media/storage/torrent
sudo nano /etc/transmission-daemon/settings.json

In the settings.json modify the following lines:

"download-dir": "/media/storage/torrent/complete",
"incomplete-dir": "/media/storage/torrent/incomplete",
"incomplete-dir-enabled": true,
"rpc-whitelist": "*.*.*.*",

Now its time to reset the BitTorrent client

sudo service transmission-daemon reload
sudo service transmission-daemon restart

That’s it. Access to your torrent client from http://192.168.1.2:9091 (considering Pi’s IP is 192.168.1.2)

Adding USB storage support to Raspberry Pi

If you have already followed the BitTorrent configuration, you most certainly need to attach a mass storage to your Pi and setup the BitTorrent client to use this storage for storing files. Open a terminal window and follow:

sudo mkdir -p /media/storage.
sudo mkfs.ext4 /dev/sda1 -L storage
sudo blkid

Here we have used blkid command to find the USB’s unique ID. Let’s consider the ID is f5a99a89-5db1-40a2-a038-6186075b85fd.
USB

Now to support USB drive with FAT partition use:

sudo nano /etc/fstab
UUID=f5a99a89-5db1-40a2-a038-6186075b85fd /media/storage  ext4  rw,noauto,users,uid=1000,gid=1000,permissions 0 2'

and for NTFS partitions use:

sudo nano /etc/fstab
UUID=f5a99a89-5db1-40a2-a038-6186075b85fd /media/storage  ext4  defaults 0 2

Now let’s take care of permissions:

sudo chown nobody.nogroup -R /media/storage/
sudo chmod 0777 /media/storage/
sudo mount -a

To have access to the sotrage from other computers in your network install samba as follows:

sudo apt-get install samba
sudo apt-get install samba-common-bin
sudo nano /etc/samba/smb.conf

Add the following to share our newly added disk driver over network:

[storage]
comment = USB Storage
path = /media/storage
writeable = Yes
only guest = Yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes

Now restart samba with sudo service samba restart. You should be able to access your storage from all local computers by now!. To get information about how much disk space is used in your USB drive use df -h /dev/sda1

References:

  1. https://en.wikipedia.org/wiki/Raspberry_Pi
  2. http://www.howtogeek.com/169679/how-to-add-a-printer-to-your-raspberry-pi-or-other-linux-computer/

Recent Posts: