WeeWX Weather Server

From Da Nerd Mage Wiki
Jump to navigation Jump to search
Proven on:
Logo Debian.png
12 (bullseye) Actually, a pretty much all default LXC running under Proxmox. Only non-default item being that I gave it 4 cores.

This particular set of instructions is based on building a Debian 12 based LXC under Proxmox to handle WeeWX. On my network, I have an existing WebServer & an existing Automation Server. The intent is to have the weather information served up as a web page (Default WeeWX thing...) by the WebServer and also be used by the Automation Server.

There is also a dedicated Database Server which we will be using. (can't possibly do things the easy way...)

(Based on: WeeWX: Installation on Debian-based systems)

Originally, the old version of this article was done with a much earlier version of WeeWX & our old Accurite weather station. Things have seriously changed since those days...

Configure apt

  • sudo apt install -y wget gnupg
  • wget -qO - https://weewx.com/keys.html | sudo gpg --dearmor --output /etc/apt/trusted.gpg.d/weewx.gpg
  • echo "deb [arch=all] https://weewx.com/apt/python3 buster main" | sudo tee /etc/apt/sources.list.d/weewx.list

Install WeeWX

  • sudo apt update
  • sudo apt install weewx

During this step, you will be asked for all the details about your install.

Fill everything in as best you can, but you can indeed change things later too.

If you are using weather station hardware that is supported by default, go ahead and select that hardware when asked. In my case, I'm currently running an EcoWitt weather station & that will require a little more effort. For now, I'm selecting Simulator as my hardware type.

Once the machine has finished churning away at the install, WeeWX will be running. You can verify this by running:

  • sudo systemctl status weewx

Setting up for EcoWitt gear

You'll be installing the Ecowitt Gateway (formerly GW1000) Driver

(Something happened to the original developer & all his stuff has vanished from the Interwebs...)

  • wget -O weewx-gw1000.zip https://github.com/hoetzgit/weewx-gw1000/archive/master.zip
  • sudo weectl extension install weewx-gw1000.zip

Verify it can talk to your EcoWitt gateway:

  • PYTHONPATH=/usr/share/weewx python3 /etc/weewx/bin/user/gw1000.py --test-driver --ip-address=device_ip_address

(Where you replace device_ip_address with the actual address of your gateway...)

You should observe loop packets being emitted on a regular basis. Once finished press ctrl-c to exit.

Note: You will only see loop packets and not archive records when running the driver directly. This is because you are seeing output not from WeeWX, but rather directly from the driver.

Configure WeeWX to use the driver:

  • sudo weectl station reconfigure --driver=user.gw1000

restart WeeWx

  • sudo systemctl restart weewx

(Note: I've verified this with GW1100 and GW1200 gateways so far...)

Customising WeeWX

Broadcasting over MQTT

Install paho-mqtt

  • sudo apt -y install python3-paho-mqtt

Download the WeeWX MQTT Extension:

  • wget -O weewx-mqtt.zip https://github.com/matthewwall/weewx-mqtt/archive/master.zip

Install the extension:

  • sudo weectl extension install weewx-mqtt.zip

Then edit weewx.conf to configure things for your own MQTT server

  • sudo vim /etc/weewx/weewx.conf

Scroll down & find the [[MQTT]] block, then edit it to suit your network.

   [[MQTT]]
       server_url = mqtt://Machine.Domain.TLD:1883
       topic = weather
       unit_system = METRIC

restart WeeWx

  • sudo systemctl restart weewx

Connecting to a remote database

By default, WeeWX uses a local instance of SQLite.

But, you may wish to archive its data on your primary database.

(Maybe even go nuts & set up multiple weather stations, all sending their data to a central database server...)

Setting up the database (MySQL / MariaDB)

On the Database Server:

(NOTE: Your Database Server must be configured to allow remote access.)

  • sudo mysql -u root -p
CREATE USER 'weewx'@'Machine.Domain.TLD' IDENTIFIED BY 'weewx';
CREATE DATABASE weewx;
GRANT select, update, create, delete, insert, drop ON weewx.* TO weewx@'Machine.Domain.TLD';

(Machine.Domain.TLD, of course, being the address of your WeeWX Server...)

Configuring WeeWX to use this database

  • sudo vi /etc/weewx/weewx.conf

in [[wx_binding]]

change

database = archive_sqlite

to

database = archive_mysql

in [[MySQL]]

change

host = localhost

to

host = Machine.Domain.TLD

(Machine.Domain.TLD, of course, being the address of your Database Server...)

restart WeeWx

  • sudo systemctl restart weewx

Making the weather visible via Web Browser

There are 3 options for locally serving up the weather as HTML...

1: Install a web server on the same machine (or VM...or LXC...)

Install your choice of web server and simply point the root at /var/www/html/weewx

2: Use FTP to upload to your existing WebServer

(Your Web Server will need to have FTP enabled...)

  • sudo vi /etc/weewx/weewx.conf

Find the [[FTP]] block & edit it to suit.

[StdReport]
    [[FTP]]
        skin = Ftp
        enable = true
        server = Machine.Domain.TLD
        path = /var/www/html/weewx
        user = USERNAME
        password = PASSWORD

3: Use RSYNC to upload to your existing WebServer

(You will need to set up passwordless SSH between this machine & your web server...)

  • sudo vi /etc/weewx/weewx.conf

Find the [[RSYNC]] block & edit it to suit.

[StdReport]
    [[RSYNC]]
        skin = Rsync
        enable = true
        server = Machine.Domain.TLD
        path = /var/www/html/weewx
        user = USERNAME

(Make sure your chosen user has write permissions...)

OTHER CUSTOMISATIONS

There is a configuration file at:

  • /etc/weewx/weewx.conf

that holds most (if not all) of the little details & tweaks for your weather server.

Administration

Checking status:

  • sudo systemctl status weewx

Starting:

  • sudo systemctl start weewx

Stopping:

  • sudo systemctl stop weewx

Restarting:

  • sudo systemctl restart weewx

Watching the system log

  • sudo journalctl -u weewx