このブログを検索

2019/01/18

Raspberry Pi 2 Model B V1.1

コンソールケーブルをつなぐ

黒→GND
黄色→GPIO14(TXD0)
オレンジ→GPIO15(RXD0)

シリアルポートのスピードは115200

WLANの設定

pi@raspberrypi:~$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
        ssid="XXXXXXXXXXX"
        #psk="xxxxxxxxxxxx"
        psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

pskを暗号化するコマンド

pi@raspberrypi:~$ sudo wpa_passphrase SSID password
network={
        ssid="SSID"
        #psk="password"
        psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

このコマンドを上記ファイルにリダイレクトすれば設定が書き込める


wlan0をdhcpにする設定


pi@raspberrypi:~$ sudo cat /etc/network/interfaces
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp


以前固定IPにしていた場合、
これだけではダメで、下記ファイルも直す

pi@raspberrypi:~$ sudo cat /etc/dhcpcd.conf

hostname
clientid
persistent
option rapid_commit

option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname

interface wlan0
#static ip_address=192.168.0.100/24
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1


sudo ifdown wlan0
sudo ifup wlan0

をやると、IPを取る。


pi@raspberrypi:~$ sudo ifup wlan0
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.3.1
DHCPACK from 192.168.3.1
RTNETLINK answers: File exists
bound to 192.168.3.12 -- renewal in 37717 seconds.
pi@raspberrypi:~$

pi@raspberrypi:~$ sudo ping yahoo.com
PING yahoo.com (98.137.246.7) 56(84) bytes of data.
64 bytes from media-router-fp1.prod1.media.vip.gq1.yahoo.com (98.137.246.7): icmp_seq=1 ttl=54 time=147 ms
64 bytes from media-router-fp1.prod1.media.vip.gq1.yahoo.com (98.137.246.7): icmp_seq=2 ttl=54 time=145 ms
64 bytes from media-router-fp1.prod1.media.vip.gq1.yahoo.com (98.137.246.7): icmp_seq=3 ttl=54 time=145 ms
^C
--- yahoo.com ping statistics ---
4 packets transmitted, 3 received, 25% packet loss, time 3004ms
rtt min/avg/max/mdev = 145.634/146.144/147.034/0.631 ms
pi@raspberrypi:~$