Campus, Linux, Networking, Opensource, python, RaspberryProject

Raspberry Beginners Guide

This guide is aimed at helping newcomers to the the Raspberry Pi (or Linux in general) get up and running with their fantastic new toy and move on to the fun stuff.

I’m going to assume you have the Model B (although most of this will work for Model A too – with the exception of the VNC setup) and some form of Windows.

We’ll be installing the Raspbian “wheezy” Debian Linux distribution for Raspberry Pi. If your using the old “squeeze” distro then upgrade now! The Raspbian “wheezy” distribution is much faster.

What you need

You’ll need the following bits and pieces:

  • A Raspberry Pi of course. Head over to Farnell/element14 or RS Components pick one up. I’d strongly recommend the Model B as this has an Ethernet port for easy access to your home network
  • A compatible SD Card. This is important, I had a few Class 6 Kingston cards and assumed they would work. They didn’t. Checkout the list of compatible SD cards over at eLinux. Or buy a bundle with compatible card (some come with Linux pre-installed). Go for a 4GB card minimum.
  • Micro USB Power Cable. Any micro USB cable or phone charger will do, or pick one up when you purchase the Pi. You can power it from mains, computer USB port or even one of those portable USB power supplies!
  • TV/Monitor* with either HDMI or Composite in (HDMI highly recommended)
  • USB Keyboard and Mouse*.

* The TV/Monitor, Keyboard and Mouse are semi-optional. If you have the Model B Raspberry Pi we can remote desktop into the Pi from any Windows or Linux pc/laptop connected to the network. We’ll just need the TV keyboard etc to do the initial setup.

Installing Linux on your SD Card

We’ll be using the Debian Raspbian “wheezy” Linux distribution here as it comes with a lot of examples and apps right out the box. Head over to the Raspberry Pi Downloads section to grab it.

You’ll also need Win32 Disk Imager to write the downloaded image. Make sure you click on the right download and not one of the annoying ads made to look like the download (you should always stay on http://www.softpedia.com).

  • Unzip the Linux download
  • Run Win32DiskImager (if you have issues right click and run as Administrator)
  • Select the *.img image file you unzipped
  • Select SD card Drive (make sure its the SD Drive and not c: or any other drive you need)
  • Click Write
  • When done remove the SD card and insert into the Raspberry Pi

Note: if you need to reuse the SD Card in Windows again you may find it can’t be read or shows a very small capacity. If so you need to re-write the file system. I found the easiest way was to put the card into a digital camera and format from there. You should now be able to read the card in Windows.

Running the Raspberry Pi Desktop

Right, now we’re getting somewhere. Make sure the SD card is inserted and the Pi is connected to the TV.

Now connect the power. You should see the Pi kick into life. Don’t worry if you see some errors here, let it finish and you’ll get to a login prompt.

If you are having trouble booting, take a look at the above section on compatible SD cards again.

The default username and password are:

Username: pi
Password: raspberry

When you hit the command prompt enter the following to launch the desktop:

startx

Congratulations! You now have a fully working desktop environment on £20 computer!

Updating and Upgrading Debian Raspbian “wheezy” Linux Distribution

Before you begin to install any software it’s best to make sure the package index files are up-to-date (essentially just a file pointing to the latest version of compatible software – for example when we install VNC later in the guide). Make sure you have an internet connection and run the following command. It may take a few minutes.

sudo apt-get update

Followed by:

sudo apt-get upgrade

Now’s also a good time to make sure the who Linux distribution is up-to-date. You can do this now, or later (it may take a while). Again make sure you have an internet connection and run:

sudo apt-get dist-upgrade

You can run these commands every now and again to make sure you have the latest software. If you’re asked to confirm anything, just hit ‘y’ on the keyboard.

Installing VNC on the Raspberry Pi for Remote Access

You may find it a bit cumbersome having a keyboard and mouse connected to the Raspberry Pi. What’s the point in having a computer smaller than your TV remote if you need to connect a massive Keyboard?

Installing VNC will allow for remote access via laptop etc while the Pi remains hidden away behind the TV or next to the router.

Giving the Pi a Static IP Address

So we always know where the Pi is let’s give it a static IP address. if you’re not sure what your local network range is open a command prompt from a Windows PC.

Start > Run and enter:

cmd

Now type:

ipconfig

You should see something like:

IPv4 Address. . . . . . . . . . . : 192.168.1.137
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

We give the Pi the same details excluding the last 3 digits of the IPv4 Address. Let’s make it easy to remember:

192.168.1.150

Back in the Raspberry Pi goto the command prompt again, don’t start the desktop.

Type:

sudo nano /etc/network/interfaces

This will bring up the network interface configuration file in the nano text editor. The word sudo simply runs this command with super user privileges.

You can save yourself a lot of time at the Linux command prompt by using Tab to auto complete.

You should see:

iface lo inet loopback
iface eth0 inet dhcp

Change this to (your IP details maybe different depending what you got from ipconfig):

iface lo inet loopback
iface eth0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1

Use Ctrl X to exit. Hit Y when prompted to save.

Now restart the network interface to apply changes without a reboot:

sudo /etc/init.d/networking stop

Followed by (can you guess?):

sudo /etc/init.d/networking start

Now your Raspberry Pi will always have the same IP address. Try pinging it from the Windows command Prompt:

ping 192.168.1.150

Installing VNC on the Pi

We’re going to use Tight VNC here (server on the Raspberry Pi and Viewer on Windows).

There’s an excellent tutorial over at Penguin Tutor if you need more information.

First of all install the Tight VNC Server from the command prompt:

sudo apt-get install tightvncserver

Let it finish installing (if you’re asked to confirm anything, just hit ‘y’ on the keyboard). When complete start the server:

vncserver

You’ll be asked to create a password, enter one and confirm. I used raspberry for ease of use, but probably not the most secure!

When asked to create a view only password, say No.

Every time you start VNC you’ll see something like:

New 'X' desktop is raspberrypi:1

Note the :1. This is the desktop session created. You can add more by running VNC again.

Head over to TightVNC on your windows box and install the viewer.

To connect run the VNC Viewer and enter:

192.168.1.150:1

Tight VNC Login

Where the IP address matches the one entered before and :1 matches desktop session.

When prompted enter the Password used when installing VNC Server.

The VNC Connected to Raspberry Pi

Start VNC Server Automatically on Bootup

There’s no point in having VNC if you have goto to the Pi, login and start the server manually. So let’s start it on bootup before the login prompt.

Create a new file in the init.d directory:

sudo nano /etc/init.d/tightvncserver

Enter the following details:

#!/bin/sh
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
    start)
        su $VNCUSER -c '/usr/bin/tightvncserver :1'
        echo "Starting TightVNC Server for $VNCUSER "
        ;;
    stop)
        pkill Xtightvnc
        echo "TightVNC Server stopped"
        ;;
    *)
        echo "Usage: /etc/init.d/tightvncserver {start|stop}"
        exit 1
        ;;
esac
exit 0

Give the script executable permission:

sudo chmod 755 /etc/init.d/tightvncserver

We can now start or stop the service manually:

sudo /etc/init.d/tightvncserver start
sudo /etc/init.d/tightvncserver stop

But let’s make Tight VNC Server start every time the Raspberry Pi starts up:

sudo update-rc.d tightvncserver defaults

Now just power off the Raspberry Pi. Make sure it’s connected to the network and power back on. You can now connected across the network using the VNC Viewer!

The Raspberry Pi Config Tool

The Raspberry Pi Configuration Tool (aka Raspi-config) is a very useful tool pre-packaged with the Raspbian “wheezy” distro. You’ll probably see it during installation; but you can launching manually for the terminal with the following command:

sudo raspi-config

Raspi-config

I’d recommend running the following as soon as possible:

  • expand_rootfs: This will expand the file system to the full size of your SD card; allowing you to use the full capacity for programs etc.
  • change_pass: Change the default password!
  • change_locale: Change your location. This will be used by some 3rd party installer to install the correct config for your setup.
  • change_timezone: Change the timezone so, well, so you have the right time.

Useful Terminal Commands

Shutdown your Pi in 1 minute:

sudo shutdown -h 1

Reboot your pi in 1 minute:

sudo shutdown -r 1

Get manual for any command:

man [command]

e.g.

man shutdown

Enjoy!

source: http://www.neil-black.co.uk/raspberry-pi-beginners-guide

Advertisements
Standard
Ini Ceritaku Mana Ceritamu, Linux, Opensource, python, RaspberryProject

Lampu kelap-kelip ala Pi.

Tadi di kampus ngoprek si Pai biar bisa kedip” gitu, Awal nya dari aksi Show ON nya @muhammadseptyan yang dengan keren nya bikin led yang nyambung ke GPIO Pai bisa nyala dengan program python (BUKAN ULER GAN!).

Awal nya ide gw, gimana tu LED bisa kedap-kedip. alhasil di coba lah. googling sana sini, gak dapet. hahaha, betapa idiot nya gw. padahal punya ebook “Getting Started With Raspberrypi O’relly” . Akhir nya buka tu ebook. ternyata ada di Chapter 8.

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.OUT)
while True:
GPIO.output(25, GPIO.HIGH)
time.sleep(1)
GPIO.output(25, GPIO.LOW)
time.sleep(1)

diatas itu kodingan nya. Gw masih belum paham dengan penjelasan nya. Maklum baru banget terjun ke embeded (padahal gw anak Sistem Komputer :-p )

gw sempet liat di hp nya –> @muhammadseptyan ada datasheet dari port GPIO yang bentuk nya kayak gini.

P1 Header Pinout, top row:

Pin Number Pin Name Rev1 Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P1-02 5V0 Supply through input poly fuse
P1-04 5V0 Supply through input poly fuse
P1-06 GND
P1-08 GPIO 14 Boot to Alt 0 -> UART0_TXD ALT5 = UART1_TXD
P1-10 GPIO 15 Boot to Alt 0 -> UART0_RXD ALT5 = UART1_RXD
P1-12 GPIO 18 PCM_CLK ALT4 = SPI1_CE0_N ALT5 = PWM0
P1-14 GND
P1-16 GPIO23 ALT3 = SD1_CMD ALT4 = ARM_RTCK
P1-18 GPIO24 ALT3 = SD1_DAT0 ALT4 = ARM_TDO
P1-20 GND
P1-22 GPIO25 ALT3 = SD1_DAT1 ALT4 = ARM_TCK
P1-24 GPIO08 SPI0_CE0_N
P1-26 GPIO07 SPI0_CE1_N

P1 Header Pinout, bottom row:

Pin Number Pin Name Rev1 Pin Name Rev2 Hardware Notes Alt 0 Function Other Alternative Functions
P1-01 3.3 V 50 mA max (01 & 17)
P1-03 GPIO 0 GPIO 2 1K8 pull up resistor I2C0_SDA / I2C1_SDA
P1-05 GPIO 1 GPIO 3 1K8 pull up resistor I2C0_SCL / I2C1_SCL
P1-07 GPIO 4 GPCLK0 ALT5 = ARM_TDI
P1-09 GND
P1-11 GPIO17 ALT3 = UART0_RTS ALT4 = SPI1_CE1_N ALT5 = UART1_RTS
P1-13 GPIO21 GPIO27 PCM_DOUT / reserved ALT4 = SPI1_SCLK ALT5 = GPCLK1 / ALT3 = SD1_DAT3 ALT4 = ARM_TMS
P1-15 GPIO22 ALT3 = SD1_CLK ALT4 = ARM_TRST
P1-17 3.3 V 50 mA max (01 & 17)
P1-19 GPIO10 SPI0_MOSI
P1-21 GPIO9 SPI0_MISO
P1-23 GPIO11 SPI0_SCLK
P1-25 GND

source: http://elinux.org/RPi_Low-level_peripherals

Colour legend
+5 V
+3.3 V
Ground, 0V
UART
GPIO
SPI
I²C
Standard
Ini Ceritaku Mana Ceritamu, Networking, Opensource, RaspberryProject

Raspberry Running For The First Time

Ok. ngebahas awal gimana akses raspberry pi.  nih pict muka serius gw sama temen gw yg kepo bet sama alat ini.

131118-150908

ternyata pi ini udah di set shh server sama temen gw @muhammadseptyan . so, gw tinggal masuk pake putty. setelah gw masuk,, JEBRETTT!!!.. biasa Layar item gosong nan memuakan, masih blm bisa melihat keindahan GUI nan eksotis itu #LEBHAYYY.

Singgkat cerita, gw tether android gw ke leptop gw yang pake WINDOWS ORIGINAL!!. gw bridge internet nya ke interface lan yg nyambung ke pi trus gw install tightvnc, dan gw akses pake tiger vnc dari WINDOWS ORIGINAL!! gw , hehehehe . (gk diajarin nih di kampus, ast lab idiot semua!!). dan hasil nya… jreng..jreng//

dok.PI1mantap!!! 🙂

Ok, gw akan lanjut pembahasan installasi SSH dan VNC nya!

#1 install SSH.

baca disini boss –> http://www.raspberrypi.org/phpBB3/viewtopic.php?f=36&t=21067 hehehe

#2 install VNC

$ sudo apt-get install vncserver
$ vncserver
//setelah perintah itu lo disuruh masukin password, masukin aje dulu.. kalo udah..tinggal akses ip si pi pake tigervnc
vnc
dan hasil nya ya begini.
pi

Standard