投稿

8月, 2023の投稿を表示しています

GPIO

 ,--------------------------------. | oooooooooooooooooooo J8   +====== | 1ooooooooooooooooooo  PoE |   Net |  Wi                    1o +====== |  Fi  Pi Model 4B  V1.5 oo      | |        ,----. +---+         +==== | |D|    |SoC | |RAM|         |USB3 | |S|    |    | |   |         +==== | |I|    `----' +---+            | |                   |C|       +==== |                   |S|       |USB2 | pwr   |hd|   |hd| |I||A|    +==== `-| |---|m0|---|m1|----|V|-------' Revision           : c03115 SoC    ...

日本語入力

 日本語入力 sudo apt update sudo apt full-upgrade sudo apt install fcitx-mozc

コマンド

アップデート&アップグレード  sudo apt update && sudo apt upgrade 温度確認 vcgencmd measure_temp

/boot/config.txt追加項目

 gpu_mem=128 hdmi_force_hotplug=1 dtoverlay=vc4-fkms-v3d dtoverlay=ov5647 dtoverlay=gpio-shutdown,debounce=1000 dtparam=pwr_led_trigger=heartbeat hdmi_enable_4kp60=1

自動起動

 $ sudo mv webiopi.service /etc/systemd/system/ $ sudo systemctl daemon-reload $ sudo systemctl start webiopi $ sudo systemctl stop webiopi $ sudo systemctl enable webiopi $ sudo systemctl disable webiopi 自動起動するサービス作成 サービス内に起動するpythonプログラムを作成(main.py) sudo nano /etc/systemd/system/main.service _______________________________________________________ [Unit] memo #Description=Play sound effects at startup #After=network.target [Service] ExecStart=/usr/bin/python3 main.py WorkingDirectory=/home/tsuyoshi [Install] WantedBy=multi-user.target __________________________________________________ サービス有効化 $ sudo systemctl enable main.service 再起動すると自動実行される。 サービス無効化 $ sudo systemctl disable   main.service サービス編集した後は更新をする systemctl daemon-reload 状態やログ確認 systemctl status    main.service [Unit] Description = サービス名 [Service] ExecStart=実行したいプログラム名 Type=simple [Install] WantedBy=multi-user.target ランレベル target 説明 0 poweroff.target システム停止 1 rescue.target シングルユーザーモード 2-4 multi-user.target ...

Pi Camera

カメラ接続確認  $  vcgencmd get_camera $ sudo nano /boot/config.txt にdtoverlay=ov5647を追記してない状態だと supported=1 detected=1, libcamera interfaces=0 dtoverlay=ov5647を追記してある状態だと supported=1 detected=0, libcamera interfaces=1 detected=1でないとRTSPの機能が働かないので dtoverlay=ov5647を追記してない状態にする。 接続カメラ機種確認 $ libcamera-vid --list-cameras プレビュー $ libcamera-hello

Agent ispy for Raspberry pie

Agent DVR https://www.ispyconnect.com/download.aspx  httpでAPIコマンドを送信して外部より録画 ------------------------------------------------------- #!/usr/bin/env python3 import requests import RPi.GPIO as GPIO gpio_sw = 2 GPIO.setmode(GPIO.BCM) GPIO.setup(gpio_sw,GPIO.IN,pull_up_down=GPIO.PUD_UP) while True:     try:         sw = GPIO.input(gpio_sw)         if sw==0:             requests.get('http://nvr.local:8090/command/alert')     except KeyboardInterrupt():         break --------------------------------------------------------

Raspberry RTSP化

  備忘録としてラズパイカメラrtsp化の手順 ①modulesなどはroot権限でないと編集できないのでrootでログインできるようにする。 $ sudo passwd root パスワードを入力する 使用するエディタをviではなくnanoにすればroot権限必要無し ①’ /etc/modulesにbcm2835-v4l2を追加。 $ su $ sudo vi /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. i2c-dev bcm2835-v4l2 ーviコマンド : を入力してからー 'o'カーソルの下行に挿入 'w'上書き保存 'q'終了 ②v4l2rtspserverをインストール。 $ sudo apt-get install cmake $ sudo apt-get install subversion $ sudo apt-get install liblivemedia-dev $sudo apt - get install libssl - dev   #音声もストリーミングする場合 $ sudo apt install libasound2 - dev $ git clone https://github.com/mpromonet/h264_v4l2_rtspserver.git $ cd h264_v4l2_rtspserver $ sudo cmake . $ sudo make install ④v4l2rtspserver起動してrtsp化 $ sudo v4l2rtspserver ⑤rtspのURLとして下記リンクを使用してiSpyに登録。 rtsp://ラズパイのIPアドレス:8554/unicast インストールしたv4l2rtspserverを次回Raspberry Pie電源ON時に自動起動する...

電源ボタン、動作表示LED

  電源シャットダウンボタン GPIOは♯3 sudo nano /boot/config.txt 末尾に下記を追加 dtoverlay=gpio-shutdown,debounce=1000 openmediavaultでシャットダウンボタンの設定 raspberry Pieの赤LEDを点滅させる sudo nano /boot/config.txt 末尾に下記を追加 dtparam=pwr_led_trigger=heartbeat

python prg1

if関数 ーーーーーーーーーーーーーーーーーーーーーーーーーーーー #!/usr/bin/env python3 a=3 b=10 c=a*b if c>30:     print(c)     print('_c>30') elif c<30:     print(c)     print('_c<30') else:     print('C=30') ーーーーーーーーーーーーーーーーーーーーーーーーーーーー for関数 ーーーーーーーーーーーーーーーーーーーーーーーーーーーー for i in range(0, 5):     #pass pass はヌル操作 (null operation) です — pass が実行されても、何も起きません。 pass は、構文法的には文が必要だが、コードとしては何も実行したくない場合のプレースホルダとして有用です。     print(i,'テスト') ーーーーーーーーーーーーーーーーーーーーーーーーーーーー ブラウザ起動 ーーーーーーーーーーーーーーーーーーーーーーー import webbrowser import time webbrowser.open('https://hibiki-press.tech/python/webbrowser_module/1884',0) time.sleep(2) webbrowser.open('https://docs.python.org/ja/3/library/intro.html#wasm-availability') ーーーーーーーーーーーーーーーーーーーーーーー

Pythonプログラム作成手順

Geany---シェルスクリプト作成用 thounny--python用 tst.pyを/home/tsuyoshiに保存。 ----------------------------------- #!/usr/bin/env python3 print('Enjoy') print('Raspberry Pi!') ----------------------------------- ターミナルで 実行属性(パーミッション)を変更 別フォルダに保存した場合は cd コマンドで移動。 $ chmod 755 test.py ーーーーーーーーーーーーーーーーーーーーーーーーーーーー パーミッション意味644 rw-r--r--通常のHTMLファイルなど。自分は読み込み、書き込みができるが、グループメンバや他人は読み込みしかできない。666 rw-rw-rw-CGIスクリプトが書き込むファイルなど。自分もグループメンバも他人も、読み込みと書き込みができる。755 rwxr-xr-x通常のディレクトリ、コマンド、CGIスクリプトなど。誰でも読込みと実行はできるが、書き込みは自分だけ。777 rwxrwxrwxCGIスクリプトがファイルを作成するためのディレクトリなど。誰でもなんでもOK。セキュリティ上は少々危険。 ーーーーーーーーーーーーーーーーーーーーーーーーーーーー ターミナルで実行 $ ./test.py