Skip to content

miyaichi/WeatherPi

 
 

Repository files navigation

WeatherPi

Weather Station for Raspberry Pi and Small LCDs
(Raspberry Pi と小型液晶向けのウェザーステーション)


Notice: DarkSky has announced the suspension of new registrations for its APIs and a close at the end of 2021. Accordingly, this repository has been modified to use the OpenWeather API.  DarkSky version is saved in "Dark_Sky_API_Version" branch, so please refer to it if you need.

注意: DarkSky は API の新規登録を停止し、2021 年末で停止することを発表しました。それに伴いこのリポジトリは OpenWeather API を利用するよう変更しています。DarkSky 版は"Dark_Sky_API_Version"ブランチに保存してありますので、必要であれば参照してください。

Dark Sky Has a New Home


Front View

480x320 en

fig: 480x320 en

240x320 en

fig: 240x320 en

Feature

  • Modularized display parts
    (表示パーツはモジュール化してあるので、カスタマイズが可能です)
  • Heat Index color / UV Index color support
    (Heat Index/UV Index で表示色を変更します)
  • Custom module support (カスタムモジュールを作成して組み込むことができます)
    External modules
  • i18n (internationalization) support
    (ロケールの変更や表示文字列の翻訳が可能です)
    I18n

Installation

install and update tools

sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install rng-tools gettext -y
sudo apt-get install python3-pygame python3-pillow -y

install WeatherPi

git clone https://github.com/miyaichi/WeatherPi.git
cd WeatherPi

copy config file and customize it

cp example.240x320.config.json config.json

or

cp example.480x320.config.json config.json

config.json

Name Default Description
openweather_appid required OpenWeather API Key
google_api_key optional Google Geocoding API key
address optional The address of a location.
latitude and longitude can be omitted if google_api_key and address are specified.
latitude
longitude
required The latitude and longitude of a location (in decimal degrees). Positive is east, negative is west.
locale required en_US.UTF-8 Locale. Specify the display language of time and weather information.
units required metric Unit of weather   information. (imperial: Fahrenheit, metric: Celsius)
SDL_FBDEV required /dev/fb1 Frame buffer device to use in the linux fbcon driver, instead of /dev/fb0.
display required Display size. [Width, Height]
fonts.name required Sans Font name.
fonts.size required {"large": 30, "medium": 22, "small": 14} Font size list. (Style name and point)

setup the services

cd
cd WeatherPi
sudo cp WeatherPi_Service.sh /etc/init.d/WeatherPi
sudo chmod +x /etc/init.d/WeatherPi
sudo chmod +x WeatherPi.py
sudo systemctl enable WeatherPi

run python with root privileges

  • this is useful if you like to run your python scripts on boot and with sudo support in python
sudo chown -v root:root /usr/bin/python3
sudo chmod -v u+s /usr/bin/python3

setting up python3 as default interpreter

  • this should start your wanted python version just by typing python in the terminal
  • helps if you have projects in python2 and python3 and don't want to hassle with the python version in your service scripts
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
  • if you use DHT11, DHT22 and AM2302 sensor, install Adafruit_DHT
sudo pip3 install Adafruit_DHT
  • if you use DigistampTemper, install pyusb
sudo pip3 install pyusb
  • if you use WeatherForcustGraph, install matplotlib
sudo pip3 install matplotlib

test

./WeatherPi.py [--debug]

Customize weather icons

By default, the OpenWeather icon is resized to display, but you can change it to any icon you like. To change the icons, place the following 18 icons in the icons folder:
(デフォルトでは OpenWeather のアイコンを表示しますが、icons フォルダに以下の 18 個のファイルを用意すれば、変更することができます。)

  • 01d.pnng, 01n.png, 02d.pnng, 02n.png, 03d.pnng, 03n.png, 04d.pnng, 04n.png, 09d.pnng, 09n.png, 10d.pnng, 10n.png, 11d.pnng, 11n.png, 13d.pnng, 13n.png, 50d.pnng, 50n.png,
Day icon name Default Night icon name Default Description
01d.png 01n.png clear sky
02d.png 02n.png few clouds
03d.png 03n.png scattered clouds
04d.png 04n.png broken clouds
09d.png 09n.png shower rain
10d.png 10n.png rain
11d.png 11n.png thunderstorm
13d.png 13n.png snow
50d.png 50n.png mist

I18n

You can change the display language of dates and information.
(日付と情報の表示言語を変更することができます。)

480x320 ja

fig 480x320 ja

240x320 ja

fig 240x320 ja

Font

Install the font for your locale. I recommend Google Fonts and Google NotoFonts.
(ロケールにあったフォントをインストールします。日本語であれば、"Noto Sans CJK JP"をインストールして、等幅フォント"Noto Sans CJK JP"を設定することを勧めます。)

How to install fonts

Translation files

  • init message.po file
cd locale
cp -Rp en <your language>
  • edit messages.po (msgstr section).
msgfmt <your language>/LC_MESSAGES/messages.po -o <your language>/LC_MESSAGES/messages.po

Modules

All modules require the following configuration:

"modules": [
  {
    "module": "<Module Name>",
    "config": {
      "rect": [<x>, <y>, <width>, <height>]
    }
  }

Built-in Modules

Name Description Options Size
Alerts Any severe weather alerts pertinent None 240x15 - 480x15
Clock Current Time None 140x60
Location Current location 140x15
Weather Current Weather icon_size (default 100) 240x100 - 480x100
WeatherForecast Weather Forecast forecast_days
icon_size (default 50)
240x80 - 480x80
SunriseSuset Sunrise, Sunset time icon_size (default 40) 80x80
MoonPhase Moon Phase icon_size (default 50) 80x80
Wind Wind direction, speed icon_size (default 30) 80x80

External modules

Name Description Options Size
DHT Adafruit temperature/humidity sensor pin: pin number
correction_value: (調整値)
60x60 - 70x120
DigistampTemper DigisparkTemper (usb temperature/humidity sensor) correction_value: (調整値) 60x60 - 70x120
IrMagitianT Temperature sensor on the infrared remote control system "irMagician-T" correction_value: (調整値) 60x35 - 70x60
JMAAlerts JMA weather alerts
(気象庁の注意報、警報、特別警報を表示)
prefecture: (都道府県)
city: (市区町村)
240x15 - 480x15
NatureRemo Temperature and humidity sensor on Nature Remo/Remo mini token: (access tokens to access Nature API)
name: (device name)
100x60
PIR PIR(Passive Infrared Ray)Motion Sensor pin: pin number
power_save_delay: delay (in seconds) before the monitor will be turned off.
None
SelfUpdate Update and restart if there is a newer version on GitHub check_interval (default 86400 # once a day) -
TEMPer TEMPerHUM/TEMPer thermometer & hygrometer correction_value: (調整値) 60x60 - 70x120
WeatherForcustGraph Plots weather condition data for the next 48 hours. conditions: Weather conditions to display.
Available weather conditions is following:
temperature, apparentTemperature, dewPoint, humidity, pressure, windSpeed, uvIndex, ozone
The size you want

Plots a graph

Temperature and humidity sensors and weather forecast data can be displayed in a graph. (温湿度センサーや気象予想データをグラフで表示することができます。)

  • Temperature and humidity sensor modules (DHT, DigisparkTemper, IrMagitianT, NatureRemo, TEMPer) Each module holds the last 6 hours of sensor data and can display it graphically. To plot the graph, define the graph drawing area with "graph_rect" parameter in the module config. (各モジュールは過去6時間分のセンサーデータを保持して、それをグラフで表示することができます。グラフを表示するには、モジュールの config に"graph_rect"パラメータでグラフの描画領域を定義します。)

    example config:

    {
      "module": "<Module name>",
      "config": {
        "rect": [x, y, width, height],
        ...
        "graph_rect": [x, y, width, height]
      }
    }
    
  • WeatherGorcustGraph module It can graphically displays the weather data for the next 48 hours or 7 days provided by OpenWeather. To plot the graph, define up to two weather condition names with the conditions parameter in the module's config. (OpenWeather が提供する今後 48 時間または 7 日間の天気データをグラフィカルに表示できます。グラフを表示するには、モジュールの config に conditions パラメータで気象条件名を最大2つまで定義します。)

    fig

    example config:

    {
      "module": "WeatherForcustGraph",
      "config": {
        "rect": [x, y, width, height],
        "block": "hourly",
        "conditions": ["temperature", "humidity"]
      }
    }
    
    • Abailable block and conditions are following: (有効な block と condition は以下の通りです) hourly: temperature, apparentTemperature, dewPoint, humidity, pressure, windSpeed, uvIndex, ozone daily: precipIntensity, precipIntensityMax, precipProbability, temperatureHigh, temperatureLow, apparentTemperatureHigh, apparentTemperatureLow, dewPoint, humidity, pressure, windSpeed, windGust, cloudCover, uvIndex, uvIndexTime, visibility, ozone, temperatureMin, temperatureMax, apparentTemperatureMin, "apparentTemperatureMax

      Refer: OpenWeather API Docs

Credit

About

Weather Station for Raspberry Pi and Small LCDs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.1%
  • Shell 1.9%