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 3 years have passed since last update.

(作成中)【RaspberryPi】WebIOPiでブラウザからモータ制御

Last updated at Posted at 2020-12-26

概要

自走式カメラを作成したく、関連する情報を覚え書き。
本記事ではモータードライバ用のGPIO、PWMのWebIOPiによる制御について記載。

実行環境

MCU:Raspberry Pi Zero W
OS:Raspberry Pi OS(buster)
モータドライバ:TA7291P
駆動用モータ:FA-130(楽しい工作シリーズ(ユニット) No.168 ダブルギヤボックス・左右独立4速タイプ)

WebIOPiでGPIO制御

WebIOPiの導入

WebIOPiをダウンロード、解凍してフォルダに入る

$ wget https://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz
$ tar xvzf WebIOPi-0.7.1.tar.gz
$ cd WebIOPi-0.7.1

ブラウザで表示するGPIOの表示を修正するパッチを適用
WebIIOPiは26ピンのころのRasberryPi用に作られているため、40ピンのもので使うときは必要

$ wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi-pi2bplus.patch
$ patch -p1 -i webiopi-pi2bplus.patch

セットアップ用スクリプトを起動

$ sudo ./setup.sh

WebIOPiサービスを systemctl で操作できるようにするため設定ファイルをダウンロード
下記のフォルダに保存して再起動

$ cd /etc/systemd/system/
$ sudo wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi.service
$ sudo reboot

RasberryPi起動時にWebIOPiが自動起動するよう設定、WebIOPiのスタート、ステータス確認

$ sudo systemctl start webiopi
$ sudo systemctl enable webiopi
$ sudo systemctl status webiopi
● webiopi.service - LSB: WebIOPi initscript
   Loaded: loaded (/etc/init.d/webiopi; generated)
   Active: active (running) since Sat 2020-12-26 08:07:38 JST; 2h 2min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 2 (limit: 729)
   CGroup: /system.slice/webiopi.service
           └─791 /usr/bin/python -m webiopi -l /var/log/webiopi -c /etc/webiopi/config

ブラウザからhttp://<ラズパイのIP>:8000にアクセス
認証ダイアログが表示されるので、
ユーザー名:webiopi
パスワード:raspberry
でログイン
サンプルページが表示されれば導入完了

GPIO制御に必要なライブラリのインストール

sudo apt install pigpio

作業フォルダの作成

mkdir ~/raspi-tank/python/
mkdir ~/raspi-tank/html/

pythonのコーディング

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?