Pages

Tuesday, August 26, 2014

WeeWX with simulated data

WeeWX is a nice software that allows you to communicate with your weather station. Unfortunately I don't own a weather station (currently I'm thinking about buying one - that's why I stumbled over WeeWX) but WeeWX offers to simulate a weather station. And that is was this article is about: install WeeWX under Slackware and run it in simulator mode.
Before you can install WeeWX you need a few more python modules, at least configobj, six, pyserial and Cheetah. If you have a weather station than you might more python modules.
Start by creating a build location where you can store all your sources etc:
# mkdir /usr/src/weewx

Python module configobj:

# cd /usr/src/weewx
# wget -c "https://pypi.python.org/packages/source/c/configobj/configobj-5.0.5.tar.gz"
...
# tar xf configobj-5.0.5.tar.gz
# cd configobj-5.0.5
# python setup.py install
...
Writing /usr/lib64/python2.7/site-packages/configobj-5.0.5-py2.7.egg-info


Python module six:

# cd /usr/src/weewx
# wget -c "https://pypi.python.org/packages/source/s/six/six-1.7.2.tar.gz"
...
# tar xf six-1.7.2.tar.gz
# cd six-1.7.2
# python setup.py install
...
Writing /usr/lib64/python2.7/site-packages/six-1.7.2-py2.7.egg-info


Python module pyserial:

# cd /usr/src/weewx
# wget -c "https://pypi.python.org/packages/source/p/pyserial/pyserial-2.7.tar.gz"
...
# tar xf pyserial-2.7.tar.gz
# cd pyserial-2.7
# python setup.py install
...
Writing /usr/lib64/python2.7/site-packages/pyserial-2.7-py2.7.egg-info


Python module Cheetah:

# cd /usr/src/weewx
# wget -c "https://pypi.python.org/packages/source/C/Cheetah/Cheetah-2.4.4.tar.gz"
...
# tar xf Cheetah-2.4.4.tar.gz
# cd Cheetah-2.4.4
# python setup.py install
...
Writing /usr/lib64/python2.7/site-packages/Cheetah-2.4.4-py2.7.egg-info


Finally you can install weewx. First get the source and extract it:

# cd /usr/src/weewx
# wget -c "http://downloads.sourceforge.net/project/weewx/weewx-2.6.4.tar.gz"
...
# tar xf weewx-2.6.4.tar.gz
# cd weewx-2.6.4


WeeWX will be installed under /home/weewx by default. If you want to change the installation directory then edit the setup.cfg file like this:

# vi setup.cfg
...
#home = /home/weewx
home = /opt/weewx/2.6.4
...


Then build WeeWX:

# python setup.py build
...
changing mode of build/scripts-2.7/wee_reports from 644 to 755


And install WeeWX:

# python setup.py install
...
Writing /opt/weewx/2.6.4/bin/weewx-2.6.4-py2.7.egg-info


The next thing you need to do is to configure WeeWX. Move to your installation directory and backup the original configuration file first:

# cd /opt/weewx/2.6.4/
# mv weewx.conf weewx.conf.bak


And create the following configuration file:

# vi weewx.conf
debug = 0
WEEWX_ROOT = /opt/weewx/2.6.4/
socket_timeout = 20
version = 2.6.4

[Station]
    location = Linz, Austria
    latitude = 48.3063900
    longitude = 14.2861100
    altitude = 256, meter
    rain_year_start = 1
    week_start = 0
    station_url = http://karellen.blogspot.com
    station_type = Simulator

[Simulator]
    loop_interval = 2.5
    mode = simulator
    driver = weewx.drivers.simulator

[StdRESTful]
    [[StationRegistry]]
        register_this_station = False
    [[Wunderground]]
        rapidfire = False
    [[PWSweather]]
        log_success = True
        log_failure = True
    [[CWOP]]
        post_interval = 600
        log_success = True
        log_failure = True
    [[WOW]]
        log_success = True
        log_failure = True
    [[AWEKAS]]
        log_success = True
        log_failure = True

[StdReport]
    SKIN_ROOT = skins
    HTML_ROOT = public_html
    [[StandardReport]]
        skin = Standard
    [[FTP]]
        skin = Ftp
        port = 21
        passive = 1
        max_tries = 3
    [[RSYNC]]
        skin = Rsync
        delete = 0

[StdConvert]
    target_unit = METRIC

[StdCalibrate]
    [[Corrections]]

[StdQC]
    [[MinMax]]
        barometer = 280, 1200, hPa
        outTemp = -40, 120, degree_C
        inTemp = 10, 120, degree_C
        outHumidity = 0, 100
        inHumidity = 0, 100
        rain = 0, 60, cm
        windSpeed = 0, 120, km_per_hour

[StdArchive]
    archive_database = archive_sqlite
    stats_database = stats_sqlite
    archive_interval = 300
    archive_delay = 15
    record_generation = hardware
    loop_hilo = True
    archive_schema = user.schemas.defaultArchiveSchema
    stats_schema = user.schemas.defaultStatsSchema

[StdTimeSynch]
    clock_check = 14400
    max_drift = 5

[Databases]
    [[archive_sqlite]]
        root = %(WEEWX_ROOT)s
        database = archive/weewx.sdb
        driver = weedb.sqlite
    [[stats_sqlite]]
        root = %(WEEWX_ROOT)s
        database = archive/stats.sdb
        driver = weedb.sqlite

[Engines]
    [[WxEngine]]
        prep_services = weewx.wxengine.StdTimeSynch
        process_services = weewx.wxengine.StdConvert, weewx.wxengine.StdCalibrate, weewx.wxengine.StdQC
        archive_services = weewx.wxengine.StdArchive
        restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS
        report_services = weewx.wxengine.StdPrint, weewx.wxengine.StdReport


Just a few mentions about the configuration file:

[Station]
Contains the information where the station is setup etc. Just search the web for yours cite latitude etc. It also contains the station type, in this case simulator.

[StdConvert] and [StdQC]
Defines which units to use.

[Databases]
Defines the database backend.

As you can see above I use non US units like cm, degree in celsius and so on. The same has to be configured for the skin so that the right values will be displayed. Go to the skin folder and edit the file skin.conf (if you need/want to change something or even all):

# cd /opt/weewx/2.6.4/skins/Standard
# vi skin.conf
...
        group_altitude     = meter
        group_degree_day   = degree_C_day
        group_direction    = degree_compass
        group_moisture     = centibar
        group_percent      = percent
        group_pressure     = hPa
        group_radiation    = watt_per_meter_squared
        group_rain         = cm
        group_rainrate     = cm_per_hour
        group_speed        = km_per_hour
        group_speed2       = km_per_hour2
        group_temperature  = degree_C
        group_uv           = uv_index
        group_volt         = volt
...


As you can above I use meter instead of foot etc.
Now it is time to start WeeWX finally:

# /usr/bin/python /opt/weewx/2.6.4/bin/weewxd /opt/weewx/2.6.4/weewx.conf -d -p /var/run/weewxd.pid

Check that WeeWX is really running:

# pgrep -fl weewx
1101 /usr/bin/python /opt/weewx/2.6.4/bin/weewxd /opt/weewx/2.6.4/weewx.conf -d -p /var/run/weewxd.pid


WeeWX will generate a few simulated data now. After ca. five minutes a new directory public_html will be created which contains all web based data. The data itself will be stored in the archive folder (if sqlite was defined).
Now it is time to configure Apache. First create the extra configuration file for weewx:

# vi /etc/httpd/extra/weewx.conf
Alias /weewx /opt/weewx/2.6.4/public_html
<Directory /opt/weewx/2.6.4/public_html>
  Options FollowSymlinks
  AllowOverride None
  Order allow,deny
  Allow from all
  #Require all granted
  AuthType Basic
  AuthName "weewx"
  AuthBasicProvider file
  AuthUserFile /opt/weewx/2.6.4/users
  Require user weewx
</Directory>


As you can see above the configuration file points to the public_html file in the WeeWX installation directory. A basic authentication is required and the user is stored in /opt/weewx/2.6.4/users for the user weewx. Next you need to create the user file with the password:

# htpasswd -c /opt/weewx/2.6.4/users weewx
New password: It'satrap!
Re-type new password: It'satrap!
Adding password for user weewx


Now make sure that Apache has PHP support and that the extra configuration file for WeeWX will be loaded:

# vi /etc/httpd/httpd.conf
...
Include /etc/httpd/mod_php.conf
...
Include /etc/httpd/extra/weewx.conf


In case that Apache is not running already start Apache:

# chmod 755 /etc/rc.d/rc.httpd
# /etc/rc.d/rc.httpd start


Otherwise just restart Apache:

# /etc/rc.d/rc.httpd restart

When the public_html directory has been created you can navigate with your webbrowser to the WeeWX address, eg:

http://192.168.10.5/weewx/

Enter username and password (eg. weewx / It'satrap! like above) and WeeWX with some graphs based on simulated data should appear:








Since I don't own a real weather station (perhaps I'll have one soon) it's pretty useless to run WeeWX standalone. On the other hand even with only simulated data WeeWX is very interesting and worth a look. For supported hardware, more in depth documentation and so on visit the project's website:

http://www.weewx.com/

No comments:

Post a Comment