…生活與工作…個人的生活雜記….

安裝與中文化WeeWX,使用氣象站misol HP2000

2021年入手的一組便宜的氣象站,之前的Oregon氣象站因為太陽能板浸水導致溫度感測器與雨量感測器整組報銷,後來用NODEMCU+BME280重新建立又因風速計斷掉(攤手

後來買的這一組是整合型氣象站,雖然聽說太陽能板也是問題多多,但是就便宜啊。

找小包施工
拿廢棄的衛星天線支架安裝

不廢話,講今天的主題:

在這個教學中,我們將指導您如何在QNAP裝置上使用Container Station安裝並設定WeeWX,並且讓misol HP2000氣象站可以使用WeeWX提供個人化氣象網頁。

安裝WeeWX

WeeWX 是用 Python 編寫的程式,它與氣象站連接並生成圖像、NOAA報告和 HTML 頁面。 可以選擇將報告上傳到遠端 Web 伺服器,也可以發佈到 WeatherUnderground、CWOP 或 PWSweather.com 等天氣服務。

QNAP使用Container Station安裝ubuntu 20.04 LXD版本,安裝方法可以google(這邊不是重點)。

WeeWX 下載點: https://weewx.com/downloads,目前最新版本是4.10

可以使用apt跟手動安裝2種方式,官方文件裡面有針對不同系統提供安裝文件。

這邊是使用NAS上的Container Station安裝ubuntu的安裝步驟,其他的作業系統安裝方式可以參考 https://weewx.com/docs/4.10/

apt安裝:

使用下面指令安裝WeeWX與相關檔案

sudo timedatectl set-timezone Asia/Taipei
sudo timedatectl set-ntp true

sudo apt-get install gpg
wget -qO - https://weewx.com/keys.html | sudo gpg --dearmor --output /etc/apt/trusted.gpg.d/weewx.gpg
wget -qO - https://weewx.com/apt/weewx-python3.list | sudo tee /etc/apt/sources.list.d/weewx.list
sudo apt-get update
sudo apt-get install weewx
sudo /etc/init.d/weewx start

手動安裝:

sudo timedatectl set-timezone Asia/Taipei
sudo timedatectl set-ntp true

sudo apt install python3-configobj python3-pil python3-serial python3-usb python3-pip python3-cheetah python3-ephem python3-pysnmp4
cd /home/weewx
sudo cp util/systemd/weewx.service /etc/systemd/system
sudo systemctl enable weewx
sudo systemctl start weewx

無論選用何種安裝方式,執行的效果都是一樣的,可以選擇最適合你的習慣的方式來使用,但是必須注意到,這2中安裝方式在系統的佈建上有些不同,必須注意範例或是文章中的指令位置配合你的使用方式修改。

apt安裝手動安裝
執行檔:/usr/bin/weewxd/home/weewx/bin/weewxd
設定檔:/etc/weewx/weewx.conf/home/weewx/weewx.conf
樣板模組:/etc/weewx/skins/home/weewx/skins/
sqlite資料庫:/var/lib/weewx//home/weewx/archive/
主頁面:/var/www/html/weewx//home/weewx/public_html/
文件:/usr/share/doc/weewx//home/weewx/docs/
範例:/usr/share/doc/weewx/examples//home/weewx/examples/
公用程式:/usr/bin/wee_*/home/weewx/bin/

設定WeeWX:

location of the weather station: 設定氣象站要顯示的名稱或是地理位置名稱

latitude, longitude of the weather station: 設定氣象站位置,如果是南緯跟西經需要多標示-,如-23.1,-121.3,台灣都不用標-。

altitude of the weather station: 氣象站高度,與氣壓有關,像我家就是70, meter(單位要加上去)。

display units: 台灣以metric為主,也就是氣溫°C、氣壓mpa、雨量cm、風速km/h。

weather station type: 目前還沒有安裝HP2000的驅動,所以先選擇 Simulator

WeeWX將會安裝在/etc/weewx ,預設網頁目錄則會在 /var/www/html/weewx

安裝misol HP2000驅動

misol HP2000跟Fine Offset HP1000, Ambient WS-1002-WiFi 相同,可以統稱為HP1000

下載點: https://github.com/AussieSusan/HP1000

安裝指令如下

cd /etc/weewx
sudo wget https://github.com/AussieSusan/HP1000/raw/master/HP1000.tar.gz
sudo tar zxvf HP1000.tar.gz
sudo python3 /usr/share/weewx/wee_extension --install HP1000
sudo python3 /usr/share/weewx/wee_config --reconfigure

之後會有類似之前安裝畫面輸入的資料

Using configuration file /etc/weewx/weewx.conf
Enter a brief description of the station, such as its location.  For example:
Santa's Workshop, North Pole
description [Weather Station in HUALIEN]:

Specify altitude, with units 'foot' or 'meter'.  For example:
35, foot
12, meter
altitude [0, meter]:

Specify latitude in decimal degrees, negative for south.
latitude [23.1]:
Specify longitude in decimal degrees, negative for west.
longitude [131.1]:

You can register your station on weewx.com, where it will be included
in a map. You will need a unique URL to identify your station (such as a
website, or WeatherUnderground link).
Include station in the station registry (y/n)? [n]:   			**這邊可以將氣象站註冊到weewx.com,我們先選n,之後再來處理

Indicate the preferred units for display: ['us', 'metric', 'metricwx']
unit system [metric]:

Installed drivers include:
  0) HP1000          (user.HP1000)
  1) AcuRite         (weewx.drivers.acurite)
  2) CC3000          (weewx.drivers.cc3000)
  3) FineOffsetUSB   (weewx.drivers.fousb)
  4) Simulator       (weewx.drivers.simulator)
  5) TE923           (weewx.drivers.te923)
  6) Ultimeter       (weewx.drivers.ultimeter)
  7) Vantage         (weewx.drivers.vantage)
  8) WMR100          (weewx.drivers.wmr100)
  9) WMR300          (weewx.drivers.wmr300)
 10) WMR9x8          (weewx.drivers.wmr9x8)
 11) WS1             (weewx.drivers.ws1)
 12) WS23xx          (weewx.drivers.ws23xx)
 13) WS28xx          (weewx.drivers.ws28xx)
choose a driver [4]: 0											**這邊要選0,使用HP1000的驅動
Saved backup to /etc/weewx/weewx.conf.20220628144501

這邊會將HP1000相關設定匯入 /etc/weewx/weewx.conf中,接下來就是設定weewx.conf了

設定WeeWX

設定檔 weewx.conf

sudo vi /etc/weewx/weewx.conf

#在[Station]之前加入
loop_on_init = True

[Station]

[HP1000]
  ip_address_mask = 192.168.1.160   #HP2000氣象站的IP
  
[StdRESTful]
  [[StationRegistry]]				#如果要註冊weewx.com就填入以下資料
    register_this_station = true
    description = #顯示的名稱
    station_url = #氣象站網址
    log_failure = true
  
[StdReport]
  [[SeasonsReport]]
    lang = utf-8

其他大致可以沿用

設定檔skin.conf

下載中文字型

推薦使用 翰字鑄造 的免費商用字體 台北黑體

下載後將字型放在 /etc/weewx/skins/Seasons/font

並修改以下參數

sudo vi /etc/weewx/skin/Seasons/skin.conf

修改參數

[CheetahGenerator]
encoding = utf-8

[ImageGenerator]
top_label_font_path = font/TaipeiSansTCBeta-Bold.ttf
top_label_font_size = 18

或使用教育部的字型

sudo apt-get install fonts-moe-standard-song

當然參數也要跟著改

sudo vi /etc/weewx/skin/Seasons/skin.conf

修改參數

[CheetahGenerator]
encoding = cn

[ImageGenerator]
top_label_font_path = /usr/share/fonts/truetype/moe/MoeStandardSong.ttf
top_label_font_size = 18

樣板 index.html.tmpl

因為HP2000沒有辦法檢測各設備狀態與電壓的功能,因此我會將這個widget關掉。

在index.html.tmpl的include “sensors.inc”多加一個#即可

sudo vi /etc/weewx/skins/Seasons/index.html.tmpl

##include "sensors.inc"

更新報告 wee_reports

使用指令就可以重新更新網頁頁面,或是等待5分鐘也可以(300秒)

sudo python3 /usr/share/weewx/wee_reports

這些就是在QNAP裝置上使用Container Station安裝並設定WeeWX,並讓misol HP2000氣象站可以使用WeeWX提供個人化氣象網頁的步驟。希望能對您有所幫助!