weather_forecast_viewer
天気予報を取得し、表示するためのレポジトリ
とりあえず動かす
ライブラリ
- pip3
- matplotlib
- numpy(upgrade)
- beautifulsoup4
- requests
- apt
- libopenjp2-7
- python3-numpy
- python3-matplotlib
- libatlas-base-dev
- fonts-ipaexfont-gothic
- fontconfig
端末上に表示
python3 ./main_emoji.py
画像として表示
python3 ./main_img.py
お天気表示デバイス導入手順
ハードウェア
Raspberry pi Zero WH
inky pHat / ACeP 7-Color
ソフトウェア
OS インストール
Raspberry Pi Imager で OS をインストールする。
以下は「Raspberry Pi OS Lite (32bit)」をインストールして進めている。
「Ctrl+Shift+X」で ssh などの設定も OS 書き込み時にやってくれるので、先に設定しておくのがおすすめ。
参考
無事に起動できたら、upgrade しておくこと。
inky pHat
inky pHat の利用
Raspberry Pi に inky pHat を取り付け、OS を起動したら以下の手順に従ってセットアップする
https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-inky-phat
example
https://github.com/pimoroni/inky
Advanced Color ePaper (ACeP) 7-Color
4 inch のカラー電子ペーパーで、Raspberry Pi に取り付け、OS を起動したら以下の手順に従ってセットアップする
https://www.waveshare.com/wiki/4.01inch_e-Paper_HAT_(F)_Manual#Working_With_Raspberry_Pi
example
https://github.com/waveshare/e-Paper.git の ここ
定期実行する方法
スクリプトを/opt 直下へ引っ越し
sudo cp -r weather_forecast_viewer/ /opt/
systemd の設定
sudo cp show_* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable show_ip.service
sudo systemctl enable show_weather.timer
sudo reboot
設定を変更したい場合
設定を変更した設定ファイルを再度/etc/systemd/system/
に置く
sudo cp show_* /etc/systemd/system/
sudo systemctl daemon-reload
設定が変更されているかはsystemctl show <unit_name>
で確認できる
sudo systemctl show show_weather.timer
エラーが出た
/usr/bin/env: ‘python3\r’: No such file or directory
対応策
sudo apt install dos2unix
dos2unix /PATH/TO/YOUR/WINDOWS_FILE
findfont: Font family 'IPAexGothic' not found.
正しく fonts-ipaexfont-gothic をインストールしていても発生する場合があります。
$ ls ~/.cache/matplotlib/
fontlist-v330.json
$ rm ~/.cache/matplotlib/fontlist-v330.json
※fontlist-v330.json
は違う名前の場合があります
メモ
systemd
- Raspberry Pi で systemd を使ってプログラムを自動実行する
- systemd タイマーの書き方。OnCalendar の timer 設定の記述方法とチェック方法をおさらいする。cron の代替にするサンプル集
- systemd .timer について調べた事を記事にしておく
- systemd で timer の作り方(最小限のサンプル)
- crontab を捨て systemd に定期実行を任せよう
- RasPi のプログラムを自動起動に!その 2 systemd 編
- systemd サービスユニット覚書