1
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.

Raspberry Pi 初心者の個人的なメモ

Last updated at Posted at 2021-07-10

概要と目次

新しくRaspberryPiのセットアップが必要になったとき用に諸々のメモ
2021.07.11 新規作成
                   motion
                   picameraキャプチャのとり方
                   bluetooth接続方法
                   ポートの設定
                   仮想環境の構築
                   Google Assistant API
                   AWSIOTへのデータ送信
                   画面の解像度を変えたい
                   Lチカしたい
2021.07.14 Tensorflow Liteで物体認識 追加
                   GPIOまとめ 追加
2021.07.17 QRコードの読み取り 追加
                   picameraピントの合わせ方追加

motion(カメラ画像web配信、動体検知)

  • インストール
    sudo apt-get install motion
  • 設定
    sudo nano /etc/motion/motion.conf
  • 起動
    sudo motion -xxx
    xxx=b background mode, n=not background mode
  • 実行時にhttp://192.168.0.x:8080でwebカメラとして見れない場合
    motion.confのwebcam_localhost on を off に

picameraキャプチャのとり方

  • Piカメラでキャプチャを取る
    raspistill -o image.jpg

picameraピントの合わせ方

十字方向に出っ張りを爪などで引っ掛けて回すとフォーカスが変わる
カメラ先端から撮像面まで1-2cmくらいまでは近づけられる
近づける方に合わせるとカメラが前に出っ張ってくる
回しすぎると外れる(メカストップがない)ので注意

image.png

ssh

パスワード認証/公開鍵認証どちらも記載あり。ありがたい!

  • sshでの接続
    ssh pi@raspberrypi -p ポート番号

chmodについて

600はrw-------所有者のみ読み書き可能を示す

bluetooth接続方法

使い方は上記記事を参考
キーボードの接続がうまく行かない場合、pairしたあとにconnectするとうまくつながることがある(実際つながった)

ポートの設定

  • インストール
    sudo apt install ufw
  • 許可
    sudo ufw allow portNum
  • ステータスの表示
    sudo ufw status
  • 開始/終了
    sudo ufw enable/disable

IPアドレスの固定

他PCからDNSやGWの設定を確認することで簡単に設定できる

NextCloud-Cloudサーバを建てる

NextCloud 信頼できないドメインを介したアクセスが表示された

image.png

viコマンド(テキスト編集)の使い方

仮想環境の構築

とってもわかりやすい
例)

  • python3 -m venv env
  • source env/bin/activate

Google Assistant API

ブログを参考に、公式ページを見ながら実施。
OAuth 同意画面 を作らないとうまく行かないので注意
OK Googleするコマンド
googlesamples-assistant-pushtotalk --project-id PROJECTID --device-model-id DEVICEMODELID

専用のコマンドを作るには

AWSIOTへのデータ送信

https://tech.gmogshd.com/raspberrypi-and-awsiot/
https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/sdk-tutorials.html
基本的にはaws公式サイトを見たほうがいい。画面などイメージしづらい部分はブログ参考に

  • ENDPOINT
    例:abcde1234567890xyz-ats.iot.us-east-1.amazonaws.com
    左側の一覧(証明書やモノなど選べる欄)の一番下の方にある設定画面から飛ぶと確認できる
  • リージョンの切り替え
    右上に 米国西部 (オレゴン) のような形で地域名が書かれている部分があるので、そこをクリック
    image.png

画面の解像度を変えたい

  • Screen Configurationをデスクトップ左上スタートメニューから起動して設定する。
    初回起動時はうまく動かないことがあるので(実際動かなかった)、再起動するといいかも

Lチカしたい

素晴らしい

Tensorflow Liteで物体認識

ここのとおりやれば比較的簡単にできた
家にあったコップをコップと認識してくれて感動した!

QRコードの読み取り

QRdetect.py

cap = cv2.VideoCapture(1)
# ↓にして実行すれば動いた
cap = cv2.VideoCapture(0)

GPIOまとめ(Raspberry Pi 4B GPIOの機能はどの機種も同じ)

image.png

image.png

ピン配

image.png

通常使わないALT機能について

FL0/FL1:BCM283Xのデバッグを支援するツール用のピン
https://github.com/RPi-Distro/raspi-gpio より

ARM-TRST … ARM JTAG reset
ARM-RTCK … ARM JTAG return clock
ARM-TDO … ARM JTAG Data out
ARM-TCK … ARM JTAG Clock
ARM-TDI … ARM JTAG Data in
ARM-TMS … ARM JTAG Mode Select

PCLKD / DED / LCD_VSYNC / LCD_HSYNCD DPI_DxDisplay
→Display Parallel Interface

SAX … Secondary mem Address bus X=1.2.3...
SDX … Secondary mem Data bus X=1.2.3...
SOE_N / SE … Secondary mem. Controls
SWE_N / SRW_N … Secondary mem. Controls

https://datasheets.raspberrypi.org/cm4/cm4-datasheet.pdf
より

1
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
1
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?