FriendlyElec NanoPi R2Sを自宅ルータとして使い始めて発覚した発熱問題。一体どの程度なのか、 CPU の 温度 を読取って OpenWRT のWebUI、LuCIに表示するパッケージを見つけたので早速導入してみました。
NanoPi R2S自宅運用時の発熱
FriendlyElec NanoPi R2S(関連記事はこちら)を自宅で運用を始めて数日、その金属筐体が長時間持っていられないほどの熱を帯びていることに気づきました。
これまで自宅用ルータやAPとして使ってきた、GL-iNet GL-AR750S(関連記事はこちら)ではほんのり暖かい程度だったのでその違いに驚きつつ、継続的な温度監視の手段を探してみました。
luci-app-temp-statusでCPU温度表示
そんな折に見つけたのがこちらの luci-app-temp-status です。
GitHubページにOpenWRT主要バージョンでのインストール手順と、スクリーンショットが簡潔に掲載されており、インストールすることで、OpenWRT(関連記事はこちら)のWebUIであるLuCIのホームページに当たる、Status Overviewページに温度センサの項目が追加されるようです。
OpenWRt19.07へのインストール
NanoPi R2Sへインストールの前にまずは、APとして稼働しているGL-AR750Sへ入れてみようと思います。
OpenWRT 19.07でのインストールは、公式GitHubによると次の通り。なお、 wget が未導入の場合は、予め opkg でインストールしておく必要があります。
1 2 3 4 |
wget --no-check-certificate -O /tmp/luci-app-temp-status_0.3-3_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/19.07/luci-app-temp-status_0.3-3_all.ipk opkg install /tmp/luci-app-temp-status_0.3-3_all.ipk rm /tmp/luci-app-temp-status_0.3-3_all.ipk /etc/init.d/rpcd reload |
実際あっけなくインストール作業は終わりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
_______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt 21.02.2, r16495-bf0c965af0 ----------------------------------------------------- # uname -a Linux R2S 5.4.179 #0 SMP PREEMPT Wed Feb 16 20:29:10 2022 aarch64 GNU/Linux # wget --no-check-certificate -O /tmp/luci-app-temp-status_0.3-3_all.ipk https://github.com/gSpotx2f/packag es-openwrt/raw/master/19.07/luci-app-temp-status_0.3-3_all.ipk Downloading 'https://github.com/gSpotx2f/packages-openwrt/raw/master/19.07/luci-app-temp-status_0.3-3_all.ipk' Connecting to 20.205.243.166:443 Redirected to /gSpotx2f/packages-openwrt/master/19.07/luci-app-temp-status_0.3-3_all.ipk on raw.githubusercontent.com Writing to '/tmp/luci-app-temp-status_0.3-3_all.ipk' /tmp/luci-app-temp-s 100% |*******************************| 2738 0:00:00 ETA Download completed (2738 bytes) # opkg install /tmp/luci-app-temp-status_0.3-3_all.ipk Installing luci-app-temp-status (0.3-3) to root... Configuring luci-app-temp-status. # rm /tmp/luci-app-temp-status_0.3-3_all.ipk # /etc/init.d/rpcd reload |
LuCIのStatus Overviewページを開いてみると、Temperatureの項目は増えたものの、残念ながらセンサ無しとのこと。
こちらのソースコードによると、どうやら次の2つをデータソースとしているようです。
1 2 |
local sysHwmon = "/sys/class/hwmon" local sysThermal = "/sys/class/thermal" |
そこでターミナルで入り確認してみると、やはりどちらも存在していませんでした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# ls -l /sys/class drwxr-xr-x 2 root root 0 Jan 1 1970 bdi drwxr-xr-x 2 root root 0 Jan 1 1970 block drwxr-xr-x 2 root root 0 Jan 1 1970 devcoredump drwxr-xr-x 2 root root 0 Jan 1 1970 extcon drwxr-xr-x 2 root root 0 Jan 1 1970 firmware drwxr-xr-x 2 root root 0 Jan 1 1970 gpio drwxr-xr-x 2 root root 0 Jul 23 00:52 ieee80211 drwxr-xr-x 2 root root 0 Jan 1 1970 leds drwxr-xr-x 2 root root 0 Jan 1 1970 mdio_bus drwxr-xr-x 2 root root 0 Jan 1 1970 mem drwxr-xr-x 2 root root 0 Jan 1 1970 misc drwxr-xr-x 2 root root 0 Jan 1 1970 mtd drwxr-xr-x 2 root root 0 Jan 1 1970 net drwxr-xr-x 2 root root 0 Jan 1 1970 pci_bus drwxr-xr-x 2 root root 0 Jan 1 1970 phy drwxr-xr-x 2 root root 0 Jan 1 1970 power_supply drwxr-xr-x 2 root root 0 Jul 28 13:56 ppp drwxr-xr-x 2 root root 0 Jan 1 1970 scsi_device drwxr-xr-x 2 root root 0 Jan 1 1970 scsi_disk drwxr-xr-x 2 root root 0 Jan 1 1970 scsi_host drwxr-xr-x 2 root root 0 Jan 1 1970 spi_master drwxr-xr-x 2 root root 0 Jan 1 1970 tty drwxr-xr-x 2 root root 0 Jan 1 1970 ubi drwxr-xr-x 2 root root 0 Jan 1 1970 watchdog |
この機種では使えないことが分かったので、パッケージを削除します。
1 2 3 |
# opkg remove luci-app-temp-status Removing package luci-app-temp-status from root... # /etc/init.d/rpcd reload |
OpenWRt21.02へのインストール
次のNanoPi R2Sへインストールする前に、ターミナルからデータソースが存在するか確認しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
_______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt 21.02.2, r16495-bf0c965af0 ----------------------------------------------------- # uname -a Linux R2S 5.4.179 #0 SMP PREEMPT Wed Feb 16 20:29:10 2022 aarch64 GNU/Linux # ls -l /sys/class/ | grep 'hwmon\|thermal' drwxr-xr-x 2 root root 0 Jul 24 17:40 hwmon drwxr-xr-x 2 root root 0 Jul 24 17:40 thermal |
どちらのディレクトリも見つかりましたが、 hwmon の中は空っぽでした。
ひとまずR2Sでは使えそうなことは分かったので、公式GitHubに記載されているOpenWRT 21.02でのインストール手順を確認。パッケージのバージョンが異なるようです。
1 2 3 4 |
wget --no-check-certificate -O /tmp/luci-app-temp-status_0.3-5_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-temp-status_0.3-5_all.ipk opkg install /tmp/luci-app-temp-status_0.3-5_all.ipk rm /tmp/luci-app-temp-status_0.3-5_all.ipk /etc/init.d/rpcd reload |
インストール後、Status Overviewページを確認すると、R2SではSoCの温度が表示されました。
せっかくなので、ターミナルからデータソースを確認してみます。
1 2 3 4 |
# cat /sys/devices/virtual/thermal/thermal_zone0/temp 56363 # cat /sys/devices/virtual/thermal/thermal_zone0/temp 54583 |
以前、Raspberry Piで同様のパスからCPU温度を取り出し、ThingSpeak(関連記事はこちら)へ定期送信する仕組みをPythonで組んでいたことを思い出しました。
1 2 3 4 5 6 7 8 9 |
def get_CPUtemp(): f = open("/sys/class/thermal/thermal_zone0/temp","r") tmp = 0 for t in f: tmp = t[:2]+"."+t[2:5] f.close() return float(tmp) cputemp = get_CPUtemp() |
CPU温度だけでは寂しいので、load averageや通信速度の値と共に、ThingSpeakへ送ってグラフ化するのも面白そうです。