0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

初代Raspberry PiをWi-Fiにつなげてみた

Posted at

はじめに

今回はRaspberry Piをネットワークにつなげてみます。Raspberry Pi本体に有線LANのポートはあるものの、有線LANケーブルをつなげるとかさばってしまうので、今回はWi-Fiに接続してみます。

事前準備

家電量販店でUSBで接続できる無線LANアダプタをいろいろと探してみたのですが、対応OSにLinuxと表記されているものは見つかりませんでした(家庭でLinuxをデスクトップに使用している人は少ないでしょうから、やむなし)。
動作確認済み機器が比較的他のアダプタより多かった以下の写真のIODATAのWN-G300Uを購入しました。
berry017.JPG

設定

この無線LANアダプタをUSBハブに接続し、Raspberry Piを起動後に以下のコマンドを LXTerminalに入力します。

$ sudo lsusb

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 007: ID 04bb:0948 I-O Data Device, Inc. WN-G300U Wireless LAN Adapter

Raspberry Piで無線LANアダプタを認識できているようです。
初代Raspberry PiでWi-Fiに接続するためには以下の2つのファイルに設定を追加する必要があります。

  • /etc/network/interfaces
  • /etc/wpa_supplicant/wpa_supplicant.conf

■/etc/network/interfaces

auto wlan0               // 電源起動時にネットワークデバイスとして認識
allow-hotplug wlan0      // 抜き差しを検知
iface wlan0 inet dhcp    // DHCPで接続
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf  //設定ファイルはこちら
iface default inet dhcp

■/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="********"      // ESSID
    psk="********"             // 暗号化キー
    proto=WPA2                 // 暗号化プロトコル
    key_mgmt=WPA-PSK           // 暗号化キーの管理方法
    pairwise=CCMP              // ユニキャスト用暗号化方式
    group=CCMP                 // ブロードキャスト/マルチキャスト用の暗号化方式
}

ネットワーク接続確認

上記の設定を記述したのち、Raspberry Piを再起動します。
$ sudo reboot
そうするとRaspberry Piの再起動時に以下の通りDHCPサーバからACK応答が返ってきていることが分かります。
DSC01155.JPG

Raspberry Piを起動後に以下のコマンドを LXTerminalに入力します。
$ ifconfig
DSC01154.JPG
無事にDHCPでIPアドレスが割り振られているようです。

終わりに

無線LANアダプタは消費電力が大きすぎるのかraspberry PIは熱暴走してKernel panicになったり、USBハブにつないでもdeviceが見つからなくなったりすることがありました。冷却するように工夫しないといけないかもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?