WebIOPi はブラウザベースでラズパイを操作するためのWEBサーバで、コレを用いることでブラウザからラズパイのGPIOの状態を確認したり、GPIOをHIGH/LOWしたりすることが出来るようになります。
ラズパイ上で、バイナリをダウンロード
pi@raspberrypi:~ $ wget http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz ... `WebIOPi-0.7.1.tar.gz' に保存中 WebIOPi-0.7.1.tar.gz 100%[=======================================================>] 208.88K 885KB/s 時間 0.2s 2016-10-25 01:12:38 (885 KB/s) - `WebIOPi-0.7.1.tar.gz' へ保存完了 [213894/213894] pi@raspberrypi:~ $ tar xvzf WebIOPi-0.7.1.tar.gz pi@raspberrypi:~ $ cd WebIOPi-0.7.1/
インストールする前に、ラズパイ2,3に対応するようにパッチ当てします。これやんないとGPIOが26ピンまでしか制御できないぽいです
pi@raspberrypi:~/WebIOPi-0.7.1 $ wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi-pi2bplus.patch pi@raspberrypi:~/WebIOPi-0.7.1 $ patch -p1 -i webiopi-pi2bplus.patch patching file htdocs/webiopi.js patching file python/native/cpuinfo.c patching file python/native/gpio.c patching file python/webiopi/utils/version.py
さていよいよインストールです
pi@raspberrypi:~/WebIOPi-0.7.1 $ sudo ./setup.sh -----割愛。 Do you want to access WebIOPi over Internet ? [y/n] n WebIOPi successfully installed * To start WebIOPi foreground : sudo webiopi [-h] [-c config] [-l log] [-s script] [-d] [port] * To start WebIOPi background : sudo /etc/init.d/webiopi start * To start WebIOPi at boot : sudo update-rc.d webiopi defaults * Run ./weaved-setup.bin to install the Weaved IoT Kit and access your device over Internet * Look in /home/pi/WebIOPi-0.7.1/examples for Python library usage examples
起動停止手順は上記のログの通りです。下記のコマンドで起動します。
pi@raspberrypi:~/WebIOPi-0.7.1 $ sudo webiopi -d -c /etc/webiopi/config Default user is "webiopi" and password is "raspberry"
これでブラウザで、http://xxx:8000/ にアクセスすると画面が表示されれば完了です。
終了は、Ctrl - C 。。
Daemonで起動するには /etc/init.d で行けると書いてあるのですが、それようの設定ファイル?を置いておかないとダメなようです。以下手順。
pi@raspberrypi:~ $ cd /etc/systemd/system/ pi@raspberrypi:/etc/systemd/system $ sudo wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi.service .. 割愛 2016-10-25 01:24:22 (1.91 MB/s) - `webiopi.service' へ保存完了 [244/244] pi@raspberrypi:/etc/systemd/system $ sudo systemctl start webiopi pi@raspberrypi:/etc/systemd/system $ sudo systemctl enable webiopi Synchronizing state for webiopi.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d webiopi defaults Executing /usr/sbin/update-rc.d webiopi enable Created symlink from /etc/systemd/system/multi-user.target.wants/webiopi.service to /etc/systemd/system/webiopi.service. pi@raspberrypi:/etc/systemd/system $
これでDaemon起動の準備が出来ました。というかこれでDaemon起動しているので、あとはおなじみの/etc/init.d/xx でOKです。
Daemon停止:
pi@raspberrypi:/etc/systemd/system $ sudo /etc/init.d/webiopi stop [ ok ] Stopping webiopi (via systemctl): webiopi.service.
Daemon起動:
pi@raspberrypi:/etc/systemd/system $ sudo /etc/init.d/webiopi start [ ok ] Starting webiopi (via systemctl): webiopi.service. pi@raspberrypi:/etc/systemd/system $
インストール関連は以上。
この記事は
現在のアクセス:2586