To start off this tutorial it is assumed that you have Weewx completely set up on another server with the weather station properly connected and reporting. This tutorial will be using a Master / Slave MYSQL database that is configured like my previous blog entry.
The purpose adding Mesowx into the mix was not to add another layer of complication into the mix, but to be able to dynamically display a dataset and to have the ability to focus in on a specific type of data or date. Mesowx allows for multiple ways to access the data and even a way to input data into your MYSQL database, but I found that to be unrealiable and frankly risky to open your server to that function. We will give the Mesowx user just enough privilage to read data from the MYSQL database table and that is it. This limits the access that is available to be compramised from a web facing function.
Step 1: Requirments
- Raspberry Pi with Weewx Weather Station running
- MYSQL configured and operating
- Download Mesowx to server
If you do not have mesowx on your server log in and download it:
wget https://bitbucket.org/lirpa/mesowx/downloads/mesowx-0.4.0.tar.gz
Untar it:
tar -xvzf mesowx-0.4.0.tar.gz
Step 2: Configure Server
Now copy the important parts to a web accessible directory:
cp -R mesowx-0.4.0/web /var/www/html/meso
cd /var/www/html/meso
We need to add a user to our MYSQL database to allow mesowx to access the data. Log into the MYSQL database as root:
mysql -u root -p
CREATE USER 'mesowx'@'127.0.0.1' IDENTIFIED BY 'password';
CREATE DATABASE weewx_raw;
GRANT SELECT ON weewx.* TO 'mesowx'@'127.0.0.1';
GRANT SELECT ON weewx_raw.* TO 'mesowx'@'127.0.0.1';
FLUSH PRIVILEGES;
There are two config files that must be edited to insert your MYSQL credentials.
cp meso/include/config-example.json meso/include/config.json
nano meso/include/config.json
You need to modify the dataSource sections and make it match your MYSQL database information
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Change the config file to match what you used when you modified your MYSQL database. You should also change the section where it checks to see if updates are allowed to the database.
1 2 3 4 5 6 7 8 9 |
|
Save and close the file.
To finish up on the server you need to copy or rename the last file.
cp js/Config-example.js js/Config.js
Step 3: Configure RaspberryPi
You now need to log onto you weather station RaspberryPi to configure it to use "raw" data. This allows your website to have data more frequently then the normal five minute update. The update time will depend on the weather station, but mine is 50 seconds. Add THIS FILE to your $WEEWX_HOME/bin/user/. The file that is supplied by Mesowx WILL NOT work. I found this file after searching for a long time online in the google groups forums. I can not find where I got it from to give credit, but I didn't make it and it works!
First off we will stop weewx and add a database to MYSQL :
service weewx stop
mysql -u root -p
CREATE DATABASE weewx_raw;
GRANT select, update, create, delete, insert, drop ON weewx_raw.\* TO 'weewx'@'localhost';
FLUSH PRIVILEGES;
Now we will make changes to the weewx configuration files. $WEEWX_HOME/weewx.conf*
Add this to the DataBindings :
1 2 3 4 5 |
|
This to the Services section :
1 2 3 |
|
Add this to the very bottom of your weewx.conf :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
I would suggest restarting both weewx and MYSQL on the RaspberryPi and MYSQL on your server. My weewx.conf configuration file is available to review here