[started by Nugraha, 2014.12.01]

This page is used as a logbook for learning Raspberry Pi in Saito Group. Most of the contents are copied directly from the [[Raspberry Pi website:http://raspberrypi.org]], with some modifications.

#contents

* About Raspberry Pi [#about]

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It is capable of doing everything we would expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games.

The Raspberry Pi also has the ability to interact with the outside world. It has been  used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras.

* Before Installation [#beforeinstallation]
** Required [#required]

1. SD Card
- An 8GB class 4 SD card is recommended. NOOBS (a package manager for Raspberry Pi) can be downloaded from the Raspberry Pi's website.

2. Display and connectivity cables
- Any HDMI/DVI monitor or TV should work as a display for the Pi . For best results, use one with HDMI input, but other connections are available for older devices. Use a standard Ethernet cable for internet access.

3. Keyboard and mouse
- Any standard USB keyboard and mouse will work with the Raspberry Pi.

4. Power supply
- Use a 5V micro USB power supply to power the Raspberry Pi. Be careful that whatever power supply we use outputs at least 5V; insufficient power will cause Raspberry Pi to behave in strange ways.

** Not essential but helpful to have [#not-essential]
1. Internet connection
- To update or download software, it is recommended that we connect the Raspberry Pi to the internet either via and ethernet cable or a wifi adapter.

2. Headphones
- Headphones or earphones with a 3.5mm jack will work with Raspberry Pi.

** Plugging in Raspberry Pi [#plugging-in]

Before we plug anything into the Raspberry Pi, make sure that we have all the equipment listed above to hand. Then follow these instructions:
- Begin by slotting our SD card into the SD card slot on the Raspberry Pi, which will only fit one way.
- Next, plug in the USB keyboard and Mouse into the USB slots on the Raspberry Pi.
- Make sure that our monitor or TV is turned on, and that we have selected the right input (e.g. HDMI 1, DVI, etc)
- Then connect the HDMI cable from the Raspberry Pi to the monitor or TV.
- If we intend to connect the Raspberry Pi to the internet, plug in an ethernet cable into the ethernet port next to the USB ports, otherwise skip this step.
- When we are happy that we have plugged in all the cables and SD card required, finally plug in the micro usb power supply. This action will turn on and boot the Raspberry Pi.
- If this is the first time the Raspberry Pi and NOOBS SD card have been used, then we will have to select an operating system and configure it.
- Follow the NOOBS guide below to do this.

* Software Installation [#installation]

** NOOBS guide [#noobs-guide]

To get started with Raspberry Pi we need an operating system. NOOBS (New Out Of the Box Software) is an easy operating system install manager for the Raspberry Pi.

*** Download and extract NOOBS [#noobs-download-extract]
To get and install NOOBS, we need an SD card (8GB recommended as mentioned before), and then we can download NOOBS for free and install it on the card.
- Using a computer with an SD card reader, visit the Downloads page on the Raspberry Pi's website.
- Click on the Download ZIP button under "NOOBS (offline and network install)", and select a folder to save it to.
- Extract the files from the zip.

*** Format the SD card [#format-sd]

It is best to format the SD card before copying the NOOBS files onto it. To do this:
- Visit the SD Association's website (https://www.sdcard.org/home/) and download SD Formatter 4.0 for either Windows or Mac.
- Follow the instructions to install the software.
- Insert the SD card into the computer or laptop's SD card reader and make a note of the drive letter allocated to it, e.g. G:/
- In SD Formatter, select the drive letter for the SD card and format it.

*** Drag and drop NOOBS files [#drag-drop]

- Once the SD card has been formatted, drag all the files in the extracted NOOBS folder and drop them onto the SD card drive.
- The necessary files will then be transferred to the SD card.
- When this process has finished, safely remove the SD card and insert it into the Raspberry Pi.

*** First boot [#first-boot]

- Plug in the keyboard, mouse and monitor cables.
- Now plug in the USB power cable to the Raspberry Pi.
- The Raspberry Pi will boot, and a window will appear with a list of different operating systems that we can install. We recommend to use Raspbian ? tick the box next to Raspbian and click on Install.
- Raspbian will then run through its installation process. Note this can take a while.
- When the install process has completed, the Raspberry Pi configuration menu (raspi-config) will load. Here we are able to set the time and date for our region and enable a Raspberry Pi camera board, or even create users. We can exit this menu by using Tab on the keyboard to move to Finish.

*** Logging into the Raspberry Pi [#logging-in]
- Once the Raspberry Pi has completed the boot process, a login prompt will appear.
- The default login for Raspbian is username
 pi
with the password
 raspberry
Note we will not see any writing appear when you type the password. This is a security feature in Linux.
- After we have successfully logged in, we will see the command line prompt  
 pi@raspberrypi~$
- To load the graphical user interface, type
 startx
and press Enter on our keyboard.

* Some useful configurations [#configure]

** Set a new user, root user, and sudoer [#newuser]

 pi@raspberrypi ~ $ sudo adduser rsaito 
 pi@raspberrypi ~ $ sudo passwd root
 pi@raspberrypi ~ $ sudo visudo

 rsaito ALL etc (Copy the data for pi)
 
** Static IP [#static-ip]
- Open /etc/network/interfaces. Default is as follows:
 $ emacs /etc/network/interfaces
 
 auto lo
 
 iface lo inet loopback
 iface eth0 inet dhcp
 
 allow-hotplug wlan0
 iface wlan0 inet manual
 wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
 iface default inet dhcp
- Change the line "iface eth 0 inet dhcp" into:
 iface eth0 inet static
        address 172.17.4.xxx    #choose xxx from allowed IP address
        netmask 255.255.252.0
        network 172.17.7.0
        broadcast 172.17.7.255
        gateway 172.17.4.1
- Restart raspberry
 $ sudo reboot

** Vcxsrv or Xming  setting up [#xming]
- Reference: http://www.straightrunning.com/XmingNotes/pixming.php

Vcxsr or Xming is useful for accesing Raspberry Pi without additional display, mouse, or keyboard. Just use our Windows PC.

***Setting in Raspberry Pi [#xdm-rasp]

- We should make sure Raspberry Pi has a static IP as described before ([[Static IP configuration:http://flex.phys.tohoku.ac.jp/english/pukiwiki-e/index.php?RaspberryPi%28Open%29#static-ip]]).
- Install xdm on Raspberry Pi:
 $ sudo apt-get install xdm
 (then choose xdm as the default display manager for Raspberry Pi instead of lightdm)
- Edit /etc/X11/xdm/xdm-config for the following line:
 BEFORE:
 DisplayManager.requestPort:    0
 AFTER: 
 ! DisplayManager.requestPort:  0
- Edit /etc/X11/xdm/Xaccess for the following line:
 BEFORE:
 #*                                     #any host can get a login window
 AFTER:
 *                                      #any host can get a login window
- Save the above files, start xdm, and install some additional packages:
 $ sudo service xdm start
 $ sudo apt-get install x11-apps
 $ sudo apt-get install midori
- Create a ~/.Xdefaults file for users pi and root (in /home/pi and /root, respectively), containing one line (to display x11-apps in colour):
 *customization:-color
- Make sure Xdmcp is listening on port 177/udp
 $ netstat -ulnp | grep 177
 udp        0      0 0.0.0.0:177             0.0.0.0:*          2864/xdm
- If the results of above netstat command missing any of the information (e.g. you cannot see udp, or 177, or xdm), then it is necessary to restart the Raspberry:
 $ sudo reboot 

***Setting in Windows PC [#xming-win]
- Create a file with .xlaunch extension (e.g. PI.xlaunch) containing the following information:
 <?xml version="1.0" encoding="UTF-8"?>
 <XLaunch WindowMode="Windowed" ClientMode="XDMCP" LocalClient="False"
 Display="-1" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword=""
 PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="172.17.4.xxx"
 XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True"
 ClipboardPrimary="True" ExtraParams="-from 172.17.4.yyy" Wgl="True"
 DisableAC="False" XDMCPTerminate="False"/>
- Note: First IP address (xxx) above is the Raspberry Pi's IP address, while in the second one (yyy) is your Windows PC's IP address (please change accordingly).
- Save the .xlaunch file on Desktop and double click to run.

** VNC server and PC VNC clients [#vnc-server]

- http://lchikaamazon.hatenablog.com/ are source of information (in Japanese)

- To operate Raspberry Pi on Desktop PC, VNC server and clients are useful.

- Install VNC server:

 pi@raspberrypi ~ $ sudo apt-get install tightvncserver

- Start VNC server (Password is required to set. You need to remember.)

 pi@raspberrypi ~ $ tightvncserver

- Install VNC viewer for your Desktop PC 

 http://www.realvnc.com/download/viewer/

- Start VNC viewer by 172.17.7.154:5901 (IP address is changed to yours.)

* You can longin 172.17.4.145 (rbp-saito847) by xdmcp [#o1fca6da]
* You can longin 172.17.4.xxx (rbp-saito847) by xdmcp [#o1fca6da]

* Ruby/tk program (172.17.4.145/~rsaito/circuit) [#p26cbfd9]
* Ruby/tk program (172.17.4.xxx/~rsaito/circuit) [#p26cbfd9]

 sudo ruby LED-ruby


* TCL/tk program for LED [#tcltk]

** Programs LED-2 [#led-2]

- Main program LED-2 (Path should include ".")

 #
 sudo ./LED-set
 LED-switch
 exit 0

- Sub program LED-set (sudo command should work without password.)

-- This program is presetting the port 25.

 # http://lchikaamazon.hatenablog.com/entry/2013/11/18/171637
 #
 # Set GPIO port 
 echo 25 > /sys/class/gpio/export
 #
 cd /sys/class/gpio/gpio25
 # Set "output" for GPIO25 port
 echo out > direction
 # echo "ready"
 exit

- Sub program LED-switch (wish is installed as default.)

-- This program should work on X windows.

-- Pussing On LED (at port 25) on OFF and EXIT

-- connection 
 GRD - LED (-)  
 Port 25 - LED (+)

 #!/bin/sh
 # the next line restarts using wish \
 exec wish "$0" "$@"
 # toplabel window . ? ???????????? 
 wm title . LED-Switch
 #
 # Button .b1   (. means "top window")
 #          -text " label "      -command " treat "
 #          -fg color of labels -activebackground color when mouse comes
 #
 button .b1 -fg red -activebackground red \
       -text "On" -command { set dum [exec sudo ./R-on ]}
 button .b2 -fg black -activebackground black \
       -text "Off" -command { set dum [exec sudo ./R-off] }
 button .b3 -fg green -activebackground red \
       -text "Exit" -command exit
 # Buttons .b1 .b2 .b3 are shown by packing -expand yes (size can be changed)
 # -ipadx 10 -ipady 20 margin
 # pack .b1 .b2 .b3 -expand yes 
 # pack .b1 .b2 .b3 -ipadx 10 -ipady 10 -expand yes 
 # pack .b1 .b2 .b3 -side left  -padx 10 -pady 10
 pack .b1 .b2 .b3 -side left -padx 10 -pady 10 -ipadx 10 -ipady 10 -expand yes

Front page   Edit Diff Backup Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes