0%

Raspberry Pi Notes

Raspberry Pi Notes

本篇作業系統: Raspbian GNU/Linux 8.0 (jessie)
硬體: RASPBERRY PI 3 MODEL B
官方doc: https://www.raspberrypi.org/documentation/

格式化SD卡

官方推薦可以用這個
SD Formatte
https://www.sdcard.org/downloads/formatter_4/index.html

下載映像檔裝入SD卡

下載 NOOBS(New Out Of Box Software)
https://www.raspberrypi.org/downloads/
NOOBS是簡單的安裝器用來安裝Raspbian
解壓裡面的東西們丟到SD卡

連接硬體

  1. SD卡
  2. 滑鼠
  3. 鍵盤
  4. 螢幕(HDMI to VGA)
  5. 網路線(或使用Wifi)
  6. 電源線(mirco USB)接上電腦、行動電源等

PS:電源線最後再接

開機安裝

插上電源即可開機
語言跟鍵盤選US
並安裝Raspbian
約20~30分鐘
按下確定之後會重開機

SSH Login

連上同一網路
找內網ip $ ssh pi@192.168.0.xxx
或直接 $ ssh pi@raspberrypi.local
預設密碼為raspberry
先改密碼$ passwd pi

更改hostname

(一定兩個都要改)
$ sudo vim /etc/hosts
$ sudo vim /etc/hostname
改成想要的ex: raspberry
重開機後就可以
ssh pi@raspberry.local

自動連結隱藏SSID Wifi

ref: http://stackoverflow.com/questions/37312501/how-do-i-detect-and-connect-to-a-hidden-ssid-on-my-raspiberry-pi-3-raspbian
$ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

1
2
3
4
5
6
network={
scan_ssid=1
ssid="SSID"
psk="PASSWORD"
key_mgmt=WPA-PSK
}

$ ifconfigor$ ip a看一下, 通常叫wlan0
關掉再重啟
$ sudo ifdown wlan0
$ sudo ifup wlan0
檢查
$ ifconfig wlan0or$ ip a

固定IP

reference

1
2
3
4
5
6
7
8
9
10
# /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.199/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

改內部設定

$ sudo raspi-config
選第一個Expand FileSystem將檔案系統擴展到整個SD卡
PS:如果是用NOOBS裝的就不用

點左上的Menu找到Raspberry Pi Configuration
到Localisation

  1. Locale:
    • Language: zh(Chinese)
    • Contry: TW(Republic of China)
    • Character Set: UTF8
  2. Timezone:
    • Area: Asia
    • Location: Taipei
  3. Keyboard:
    • Country: Taiwan
    • Variant: Taiwanese
  4. Wifi Country: TW Taiwan

安裝套件

更新資源庫: sudo apt update -y
可更新的已安裝套件: apt list --upgradable
更新已安裝的套件: sudo apt upgrade -y

VIM

一般vim: sudo apt install vim
GUI版: sudo apt-get install vim-gnome

VNC server

Server

$ sudo apt-get install tightvncserver
$ vncserveror$ tightvncserver 輸入要連進去的密碼
$ vncserver -geometry 1680x1050 -depth 24 更清楚
$ netstat -tnlp 看port
$ vncserver -kill :編號 可以關閉
$ vncpasswd 可以改密碼

Client

MAC: 打開finder->工具列->前往->連接伺服器->
vnc://raspberrypi.local:5901
Windows要裝Real VNC Viewer

回傳CPU溫度

$ vcgencmd measure_temp

關機

$ sudo shutdown -h now

測試相機模組

拍照 $ raspistill -o cam.jpg
錄影五秒 $ raspivid -o 1.h264
錄影十秒 $ raspivid -o 2.h264 -t 10000s
$ raspivid -o 3.h264 -w 230 -h 240 -t 10000s
安裝vlc播放器$ sudo apt-get install vlc

安裝web interface

http://elinux.org/RPi-Cam-Web-Interface
https://github.com/silvanmelchior/RPi_Cam_Web_Interface

new photo無限迴圈

https://github.com/silvanmelchior/RPi_Cam_Web_Interface/blob/master/www/cam_pic_new.php#L31

照片

https://github.com/silvanmelchior/RPi_Cam_Web_Interface/blob/master/www/index.php#L199
http://raspberrypi.local/html/cam_pic.php

also good
https://github.com/miguelgrinberg/flask-video-streaming

安裝 node.js

1
2
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install nodejs