Category:RPI Setup

From ElectroDragon Wiki
(Redirected from Raspberry Pi Setup)

Install OS Raspbian

  • Use Noobs or Raspbian, can download from here
  • Default pasword for user pi is raspberry
  • Use USB-TTL cable connect, and setup wifi
  • enable SSH in raspi-config, then you can SSH login via wlan

Headless Setup

Config via UART, SSH

  • To enable it, add enable_uart=1 to config.txt.
  • After set wifi, also set SSH on by raspi-config

Use Wifi

  • run ifconfig to check ip address of wlan0
  • To scan for WiFi networks, use the command: sudo iwlist wlan0 scan
  • note: 1. Make sure enough power for wifi card, 2. SSID and password are case sensitive
  • After setup you can connect by SSH via Wifi
  • You can set multiple wifi configuration, open the wpa-supplicant configuration file in nano: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Go to the bottom of the file and add the following:

network={
    ssid="he_work"
    psk="Your_wifi_password"
    scan_ssid=1 # auto find and connect
}
network={
    ssid="hechao"
    psk="Your_wifi_password2"
}

Use RealVNC

curl -L -o VNC.tar.gz https://www.realvnc.com/download/binary/latest/debian/arm/
tar xvf VNC.tar.gz
sudo dpkg -i <VNC-Server-package-name>.deb [<VNC-Viewer-package-name>.deb]
  • Start service and set it on boot
sudo /etc/init.d/vncserver-x11-serviced start
sudo update-rc.d vncserver-x11-serviced defaults

Use FTP (also can use SSH default)

  • install vsftpd, and then edit the conf file:
sudo apt-get install vsftpd
sudo nano /etc/vsftpd.conf
  • The setup
anonymous_enable=NO // default, no need change, do not allow anonymous
local_enable=YES // default, no need change, allow local user login
write_enable=YES // allow upload
local_umask=002 // set upload file right 663, folder 775 , or set to 000
  • Allow root login to FTP, comment root line
sudo nano /etc/ftpusers
  • restart service after edit
service vsftpd restart

Now you can login in to RPI FTP with pi or root user.

Use Bluetooth for RPI2

  • install software: apt-get install bluetooth bluez-utils bluez-compat blueman
  • check devices, after plug in USB Bluetooth adapter: lsusb

See there is no proper equipment to identify Bluetooth Dongle, For instance, Bus 001 Device 005: ID 0a12: 0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

  • Then run
/ Etc / init.d / bluetooth status or # service bluetooth status

Bluetooth service to see whether the normal operation.

Normal, then it should be

[Ok] bluetooth is running.
  • Use this command to view visibility around the address and name of the device:
Hcitool scan

        aa: bb: cc: dd: ee: ff Wireless Keyboard         ff: ff: bb: cc: dd: aa Nokia XXXX

Run (later replaced with your device's address):

Bluez-simple-agent hci0 aa: bb: cc: dd: ee: ff

Enter a password (0000) here, Enter.

If the Bluetooth keyboard, Bluetooth devices go over there to enter the password you just set (0000) Enter.

Success should say

......

Release

...... Like: Creating device failed if the failure occurs. Please try again. Verify the Bluetooth device is in pairing request state.


............

  • Use this command (do not forget to replace the correct address) will this new device is added to the trusted list:
Bluez-test-device trusted aa: bb: cc: dd: ee: ff yes
  • Use this command to manually start the connection:
Bluez-test-input connect aa: bb: cc: dd: ee: ff

Normal setup

Use Monitor

  • Connect your RPI to TV via HDMI port, and power it up.
  • Plug the wireless device, setup your wireless environment in the graphic desktop
  • Now you can leave the TV and start with SSH, opened default in SSH
  • Install the following VNC tool for further visualization.

Raspi-config

Options:

  • enter into graphic desktop or text console
  • Disable overscan to enter fullscreen for some LCDs
  • Overclocking to get better performance!

HDMI setup

  • choose output type for audio
amixer cset numid=3 x

in which

0 = auto
1 = analog
3 = HDMI
  • or edit in raspi-config audio option
  • force to turn on HDMI audio in /boot/config.txt
hdmi_drive=2

Other Settings

  • for new raspbian version, USB stick should be auto load to directory /media/disk/
  • turn on root account
  1. set root password: sudo passwd root
  2. unlock it: sudo passwd --unlock root
  • safely shutdown
  1. reboot system: sudo shutdown -r now
  2. Halt system: sudo halt, or: sudo shutdown -h now

Sources.list

  • Sources List Update
  • Backup the orgin sources list and edit current list
pi@raspberrypi:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak  #back up to sources.list.bak
pi@raspberrypi:~$ sudo nano /etc/apt/sources.list     #edit sources.list
  • copy paste following sources and apt-get update upgrade:
deb http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
  • for jessie:
deb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib
  • Qinghua:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ wheezy main non-free contrib
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ wheezy main non-free contrib
  • Disk backup - use win32 disk imager, read or write image of SD card
  • remove or comment raspi.list source: /etc/apt/sources.list.d/raspi.list, or use another raspi source:
deb http://mirrors.aliyun.com/debian/ jessie main ui
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ jessie main ui
  • Key update: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010

obsolete

Use tightVNC (obsolete, direct setup in RPI raspi-config or desktop)

  • Install tightVNC: apt-get install tightvncserver
  • Run the service, be aware of the empty capspace in between the vncserver: vncserver :1
  • In the command above 1 is the port, so you can connect to address like 192.168.1.100:1

Method 1

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!

Method 2 obsolete

There is a known issue about the login request at booting, if you have this problem, check the section below.

  • Run VNC at startup
cd /home/pi
cd .config
mkdir autostart
cd autostart
nano tightvnc.desktop
[Desktop Entry]
Type=Application
Name=TightVNC
Exec=vncserver :1
StartupNotify=false
Boot issue

1. Boot your R-Pi 2. SSH log in with your user account (normally user: pi, password: raspberry) 3 Enter your home directory by typing

cd ~
and
ls -A
and 
mv .Xauthority .Xauthority.backup
and 
sudo chmod 777 /home/pi
and finally reboot
sudo reboot

Setup List

This category currently contains no pages or media.