ユーザ用ツール

サイト用ツール


raspberrypi

raspberrypi

ubuntuでsetup

raspedianのlightをダウンロード解凍してimgをSDカードに書き込み
ubuntuのツールを利用

etcherを利用

https://www.balena.io/etcher/

balenaEtcher-1.5.56-x64.AppImage を実行

etcherを利用すれば以下の作業は不要(SDカードのformat方法が不明)

sudo parted -l
umount /dev/mmcblk0
sudo dd if=2019-00-00-raspbian-xxxxxx-lite.img of=/dev/mmcblk0 bs=1M

ヘッドレスセットアップのための設定

シリアル設定

boot/config.txt

dtoverlay=pi3-miniuart-bt

boot/cmdline.txt dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

wifi設定

作成下SDカードのbootに以下のファイル作成

  • /boot/ssh

0バイトのファイルを作成

  • /boot/wpa_supplicant.conf (国情報が無いと動作しない)
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP

network={
	ssid="ssid"
	psk="pass"
}
wifi power

wifiアダプタの省電力設定を切る(wifiが反応悪いなら)

sudo iwconfig wlan0 power off
固定IP

固定IPにするなら /etc/dhcpcd.confに以下を追加

interface wlan0
static ip_address=192.168.0.11/24
static routers=192.168.10.1
static domain_name_servers=192.168.0.1
優先LAN(eth0)設定

* dhcpcd.confに設定を行う * metric 番号が小さい方が優先

起動

ubuntuからだとavahiが動いているのでraspberrypi.localで接続可能

ssh pi@raspberrypi.local

パスワード:raspberry

初期設定

sudo raspi-config
* network     --> Change Hostname
* boot        --> Change locale:  en_GB.UTF-8 UTF-8を解除 ja_JP.UTF-8 UTF-8 選択 Defualtを ja_JP.UTF-8
* Localisation--> Change Timezone:Asia/Tokyo
* Localisation--> Change Keyborad:
* Advanced    --> Expnad Filesystem:Expand
* IntartFacing--> ssh serial camera i2c などをenable

ユーザ変更

piユーザをnewpiに変更する

# 仮のユーザ(tmp)を作成する
sudo useradd -M tmp
# tmpユーザをsudoグループに追加(そうしないとsudoが使えない)
sudo gpasswd -a tmp sudo
# tmpユーザのパスワードを設定
sudo passwd tmp

ここでtmpでログインし直し

# usermod -lでユーザ名をpiからnewpiに変更
sudo usermod -l newpi pi
# usermod -dでホームディレクトリを/home/piから/home/newpiに変更
sudo usermod -d /home/newpi -m newpi
# groupmod -nでpiグループをnewpiグループに変更
sudo groupmod -n newpi pi

新しユーザ名でログイン

# 仮ユーザを削除(警告的なのが出るかと思いますが、構わず削除して下さい)
sudo userdel tmp
# newpiユーザのパスワードを変更
sudo passwd newpi

GPIO

SPI

raspi-config でspiを有効にする

  • SPI0:
MOSI,GPIO10
MISO,GPIO9
SCLK,GPIO11
CE0, GPIO8
CE1, GPIO7
  • SPI1:
MOSI,GPIO20
MISO,GPIO19
SCLK,GPIO21
CE0 ,GPIO18
CE1 ,GPIO17
CE2 ,GPIO16

usb-ttl-gpio

黒(GND) 6  -GPIO14番の隣のGND
白(RxD) 8  -GPIO14番ポート
緑(TxD) 10 -GPIO15番ポート
赤はどこにも繋がない

linuxからコンソール接続(ubuntu)

cu -s 115200 -l /dev/ttyUSB0
(/dev/ttyUSB は ls -l /dev/serial/by-id で接続を確認)

i2c

raspberrypiのtoolインストール

sudo apt-get install i2c-tools

raspberrypi pin配置

1:  +3.3V
2:  +5.0V
3:  SDA(I2C)
4:  +5.0V
5:  SCL(I2C)
6:  GND

i2cの接続確認

sudo i2cdetect -l

Watchdog

Raspberry Pi 3/ Zero / Zero W等で watchdogを有効化する https://qiita.com/hidenorly/items/a09486c4359e85d7583e

/boot/config.txt

dtparam=watchdog=on

/etc/modprobe.d/bcm2835-wdt.conf

options bcm2835_wdt heartbeat=20 nowayout=0

/etc/systemd/system.conf

RuntimeWatchdogSec=5

xorg

liteをセットアップした後のxwindowインストール

# pixel desktop
sudo apt install --no-install-recommends xserver-xorg
sudo apt install --no-install-recommends xinit
sudo apt install --no-install-recommends raspberrypi-ui-mods
# dwm
sudo apt install xorg
sudo apt install dwm
sudo apt install fonts-ipafont-gothic

raspberrypiでのxrog

i2c+python

照度センサBHI1750(i2c)

温度湿度センサBME280(i2c)

カメラ接続

設定

raspi-config
interfacing Options → camera

接続確認

vcgencmd get_camera  

raspberrypiでOpenCV

動画配信

解像度変更

http://dotblogrc.blogspot.com/2018/03/raspberry-pi.html

http://www.greensignal.jp/blog/?p=882

/boot/config.txt  を設定変更する

max_usb_curren=1
hdmi_force_hotplug=1
config_hdmi_boost=7
hdmi_group=2
hdmi_mode=87
hdmi_drive=1
display_rotate=0
hdmi_cvt 1024 600 60 6 0 0 0 

# custom display resolution (480x320 looks good , and 720x480 is not too bad too,3rd res is: 810x540 )
#         /----------------- Width: 480px ( or 720px /or 810px)
#         |   /------------- Height: 320px ( or 480px /or 540px)
#         |   |   /--------- Refresh: 60Hz
#         |   |   | /------- Aspect ratio: 6=15:9 (1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10)
#         |   |   | | /----- Margins: 0=disabled (1=enabled)
#         |   |   | | | /--- Interlace: 0=progressive (1=interlaced)
#         |   |   | | | | /- Reduced blanking: 0=normal (1=reduced)
#         |   |   | | | | |
hdmi_cvt=1024 600 60 3 0 0 0

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
hdmi_group=1 or 2
  (CEA=1、DMT=2)
hdmi_mode=1    640x350    85 Hz
hdmi_mode=2    640x400    85 Hz
hdmi_mode=3    720x400    85 Hz
hdmi_mode=4    640x480    60 Hz
hdmi_mode=5    640x480    72 Hz
hdmi_mode=6    640x480    75 Hz
hdmi_mode=7    640x480    85 Hz
hdmi_mode=8    800x600    56 Hz
hdmi_mode=9    800x600    60 Hz
hdmi_mode=10   800x600    72 Hz
hdmi_mode=11   800x600    75 Hz
hdmi_mode=12   800x600    85 Hz
hdmi_mode=13   800x600   120 Hz
hdmi_mode=14   848x480    60 Hz
hdmi_mode=15   1024x768   43 Hz  DO NOT USE
hdmi_mode=16   1024x768   60 Hz
hdmi_mode=17   1024x768   70 Hz
hdmi_mode=18   1024x768   75 Hz
hdmi_mode=19   1024x768   85 Hz
hdmi_mode=20   1024x768  120 Hz
hdmi_mode=21   1152x864   75 Hz
hdmi_mode=22   1280x768          Reduced blanking
hdmi_mode=23   1280x768   60 Hz
hdmi_mode=24   1280x768   75 Hz
hdmi_mode=25   1280x768   85 Hz
hdmi_mode=26   1280x768  120 Hz  Reduced blanking
hdmi_mode=27   1280x800          Reduced blanking
hdmi_mode=28   1280x800   60 Hz  
hdmi_mode=29   1280x800   75 Hz  
hdmi_mode=30   1280x800   85 Hz  
hdmi_mode=31   1280x800  120 Hz  Reduced blanking
hdmi_mode=32   1280x960   60 Hz  
hdmi_mode=33   1280x960   85 Hz  
hdmi_mode=34   1280x960  120 Hz  Reduced blanking
hdmi_mode=35   1280x1024  60 Hz  
hdmi_mode=36   1280x1024  75 Hz  
hdmi_mode=37   1280x1024  85 Hz  
hdmi_mode=38   1280x1024 120 Hz  Reduced blanking
hdmi_mode=39   1360x768   60 Hz  
hdmi_mode=40   1360x768  120 Hz  Reduced blanking
hdmi_mode=41   1400x1050         Reduced blanking
hdmi_mode=42   1400x1050  60 Hz  
hdmi_mode=43   1400x1050  75 Hz  
hdmi_mode=44   1400x1050  85 Hz  
hdmi_mode=45   1400x1050 120 Hz  Reduced blanking
hdmi_mode=46   1440x900          Reduced blanking
hdmi_mode=47   1440x900   60 Hz  
hdmi_mode=48   1440x900   75 Hz  
hdmi_mode=49   1440x900   85 Hz  
hdmi_mode=50   1440x900  120 Hz  Reduced blanking
hdmi_mode=51   1600x1200  60 Hz  
hdmi_mode=52   1600x1200  65 Hz  
hdmi_mode=53   1600x1200  70 Hz  
hdmi_mode=54   1600x1200  75 Hz  
hdmi_mode=55   1600x1200  85 Hz  
hdmi_mode=56   1600x1200 120 Hz  Reduced blanking
hdmi_mode=57   1680x1050         Reduced blanking
hdmi_mode=58   1680x1050  60 Hz  
hdmi_mode=59   1680x1050  75 Hz  
hdmi_mode=60   1680x1050  85 Hz  
hdmi_mode=61   1680x1050 120 Hz  Reduced blanking
hdmi_mode=62   1792x1344  60 Hz  
hdmi_mode=63   1792x1344  75 Hz  
hdmi_mode=64   1792x1344 120 Hz  Reduced blanking
hdmi_mode=65   1856x1392  60 Hz  
hdmi_mode=66   1856x1392  75 Hz  
hdmi_mode=67   1856x1392 120 Hz  Reduced blanking
hdmi_mode=68   1920x1200         Reduced blanking
hdmi_mode=69   1920x1200  60 Hz  
hdmi_mode=70   1920x1200  75 Hz  
hdmi_mode=71   1920x1200  85 Hz  
hdmi_mode=72   1920x1200 120 Hz  Reduced blanking
hdmi_mode=73   1920x1440  60 Hz  
hdmi_mode=74   1920x1440  75 Hz  
hdmi_mode=75   1920x1440 120 Hz  Reduced blanking
hdmi_mode=76   2560x1600         Reduced blanking
hdmi_mode=77   2560x1600  60 Hz  
hdmi_mode=78   2560x1600  75 Hz  
hdmi_mode=79   2560x1600  85 Hz  
hdmi_mode=80   2560x1600 120 Hz  Reduced blanking
hdmi_mode=81   1366x768   60 Hz  
hdmi_mode=82   1080p      60 Hz  
hdmi_mode=83   1600x900          Reduced blanking
hdmi_mode=84   2048x1152         Reduced blanking
hdmi_mode=85   720p       60 Hz  
hdmi_mode=86   1366x768          Reduced blanking

仮想キーボード

タッチパネル上で操作するため、画面上に表示するスクリーンキーボードをインストール

sudo apt-get install matchbox-keyboard
sudo apt-get install ttf-kochi-gothic

デスクトップショートカット

アプリケーションの追加削除より

lxshortcut を検索して LXDE application shortcut editor1をインストール

GUIアプリの自動実行

実行したいプログラムを .config/lxsession/LXDE-pi/autostart に指定する

@/home/pi/xxxxx.sh

最初に入れるもの

sudo apt install vim
sudo apt install subversion
  
#desktop environment
sudo apt install xinit
sudo apt install raspberrypi-ui-mods

#日本語化
sudo apt-get install ibus-mozc
raspberrypi.txt · 最終更新: 2021/01/31 17:26 by nabezo