Installing mesowx on weewx using local SQLite database

399 views
Skip to first unread message

bgra...@umw.edu

unread,
Mar 9, 2016, 11:50:56 AM3/9/16
to weewx-user
Hello,

I am interested in exploring the use of mesowx on my weewx system (VP2+ with 6540 datalogger, Debian 8). I am presently running wview with 8 years of archives. My website is on the same machine as weewx.

It seems that mesowx can use an SQLite db but I'm not certain how to connect the two. Most instructions I can locate use MySQL and I'm not sure how to configure my SQLite db. Can this be done or am I better off
attempting another approach?

My goal is to have screen (index.html) updates every 30-60 seconds as I do in wview even though my archive interval is 15 minutes. Presently, my weewx system only updates every 15 minutes when it writes to the db.

Any help on this would be appreciated. Thanks in advance.

Bob

Luc Heijst

unread,
Mar 9, 2016, 3:18:21 PM3/9/16
to weewx-user
Hi Bob,

For putting raw c.q. loop data in a local MySQL database you need MesoWx's raw.py module. Unfortunately this module isn't working anymore in weewx version 3.0 and higher.

You need to configure both files Config.json and weewx.conf, see below:

Contents of http://<YOUR-WEB-SERVER>/web/meso\/nclude/Config.json

{
    /*
     * Define your database connection(s). Multiple can be defined separated by a comman.
     * The key is the data source ID  and is used to reference the it elsewhere in the config. The
     * ID must be unique. Each data source must define a 'type' property; the only supported type
     * currently is 'mysql'. The rest of the properties required depend on the type 
     * (see examples below).
     */
    "dataSource" : {
        "weewx_mysql" : { // the data source ID
            "type" : "mysql",
            "host" : "localhost",
            "user" : "your database user",
            "password" : "your database password",
            "database" : "meso"
        },
    },
    /*
     * Define your data entities. Entities are effectively database tables containing columns
     * of your data. The key is the ID of the entity which is used to reference the entity in
     * the HTTP API. Each entity must define a 'type' property; the only supported type is 
     * currently 'table' (see examples below).
     */
    "entity" : {
        // This example shows a configuration with a retention policy
        "weewx_raw" : {
            "type" : "table",
            "dataSource" : "weewx_mysql",
            "tableName" : "raw",
            "accessControl" : {
                "update" : {
                    "allow" : true,
                    "securityKey" : ""
                }
            },
            // The retention policy defines how this data is retained over time. It is only really
            // revevant when allowing this entity to be updated. Curently the only supported
            // policy type is "window" which will retain data within the specified time window.
            "retentionPolicy" : {
                "type" : "window",
                // The trigger defines when the policy is applied. Currently only "update" is
                // supported, which means each time the entity is updated.
                "trigger" : "update",
                // The amount of time in seconds since the current date/time to retain. All records
                // before this time window will be permanently deleted!
                "windowSize" : 86400 // 24 hours
            },
            "columns" : {
                "dateTime" :    {"type" : "number", "unit" : "s"},
                "barometer" :   {"unit" : "hPa"},
                "outTemp" :     {"unit" : "c"},
                "outHumidity" : {"unit" : "perc"},
                "windSpeed" :   {"unit" : "kph"},
                "windDir" :     {"unit" : "deg"},
                "windGust" :    {"unit" : "kph"},
                "windGustDir" : {"unit" : "deg"},
                "rainRate" :    {"unit" : "cmHr"},
                "rain" :        {"unit" : "cm"},
                "dewpoint" :    {"unit" : "c"},
                "windchill" :   {"unit" : "c"},
                "heatindex" :   {"unit" : "c"}
            },
            "constraints" : {
                "primaryKey" : "dateTime"
            }
        },
    }
}
...
Change / set the following in weewx.conf:

[DataBindings]
    [[raw_binding]]
        database = raw_mysql
        table_name = raw
        manager = weewx.manager.Manager
        schema = user.raw.schema
...
[Databases]
    [[raw_mysql]]
        database_type = MySQL
        database_name = meso
...
[Raw]

    #
    # This section is for configuration of the raw plugin. This plugin stores the raw
    # data off of the station.
    #
    # The database binding to persist the raw data. 
    # This should match a section under the [DataBindings] section.
    data_binding = raw_binding
    #
    # The max amount of raw data to retain specified in hours (set to 0 to retain all data)
    # This will in effect keep a rolling window of the data removing old data based on 
    # the time of the most recent record. It is recommended to set this to at least 24.
    #
    # NOTE: if increasing this value (or setting to unlimited), keep in mind that raw data 
    # may consume VERY large amounts of space!
    data_limit = 72  # 3 days
...
[Engine]
    [[Services]]
        archive_services = weewx.engine.StdArchive, user.forecast.ZambrettiForecast, user.forecast.WUForecast, user.raw.RawService
...

Success!

Luc

Luc Heijst

unread,
Mar 9, 2016, 3:25:15 PM3/9/16
to weewx-user
Bob,

I forgot to say that MesoWX on a local machine probably won't work with a sqlite weewx archive database.
My module raw.py can handle a sqlite weewx archive database to populate a local MySQL raw database, but that is probably not enough.

Luc  

bgra...@umw.edu

unread,
Mar 9, 2016, 3:31:48 PM3/9/16
to weewx-user
Thanks for the reply, Luc. Does this mean that I need to create a MySQL database also on the local machine?

Luc Heijst

unread,
Mar 9, 2016, 3:38:58 PM3/9/16
to weewx-user
Bob,

MesoWx CAN work with a local sqlite weewx archive database, but then MesoWx has to run on a REMOTE server. On the remote server you need two MySQL databases: one with archive data and one with raw data (optional).
To populate both databases you need my modified sync_lh4.py module, see thread: https://groups.google.com/forum/#!searchin/weewx-user/sync_lh4/weewx-user/Z4sW4oDDboo/kE5n4nJcFgAJ

Luc

PS. I'm planning to put these modules with instructions on my github account. Please be patient! 

Luc Heijst

unread,
Mar 9, 2016, 3:45:38 PM3/9/16
to weewx-user
Bob,

To work with MesoWx on a local machine, the weewx database has to be a MySQL database (not 100% true, you can 'sync' the local sqlite weewx data to a local MySQL weewx database, but that is nonsense!).
So: make a dump of your sqlite weewx database. Install MySQL on the local machine and fill the MySQL weewx database with the database dump. Then use my module raw.py to populate a local MySQL raw datrabase.

Luc

Luc Heijst

unread,
Mar 9, 2016, 3:59:20 PM3/9/16
to weewx-user
Sorry Bob,

I didn't read your post carefully. When you only want to use MesoWX to show live (that is raw cq. loop) data, you can work locally with a sqlite weewx archive database and a MySQL raw database which will be populated by my modified raw_lh4.py module.
You need indeed to install MySQL on your local machine for the raw database. Configure MesoWX so that it doesn't show the archive data.

Luc

bgra...@umw.edu

unread,
Mar 9, 2016, 5:46:54 PM3/9/16
to weewx-user
Thanks, Luc, I'll play around with this idea. I may have more questions.  Bob
Reply all
Reply to author
Forward
0 new messages