Publishing Weather Station data to Third Party Websites – Part 9

From Beginning: An Introduction – Part 1

Previous: Automatically Publish Current Conditions to a Twitter Account – Part 8

If you want to publish your weather station’s data to sites like Weather Underground, WeatherCloud, or PWSWeather, you can certainly do that as well.

As far as I can tell, it is no longer possible to share weather station data with Weather Underground using the Raspberry Pi. Even though the Weewx software config (.conf) file still has a section for it. I added my newest weather station to my WU account, and added the WU Station ID, and tried my WU password. When that didn’t work, I tried my station ‘Key’. Saving the config file and restarting Weewx after each change. Hours later it still shows as “offline”.

A couple of blog and forum posts I have found seem to indicate that Weewx is configured to use the WU API to upload data. That API is no longer free to use, so it ignores data that tries to use it.

With that said, if you’re determined to publish to WU, and you have an Acurite station, you can buy a device like the Acurite Access (if you’re using an Acurite weather station). Last I checked, it’s $159 on Amazon. The Access apparently communicates with WU differently and publishes data without issue. I have purchased two Access devices for my first two weather stations, but I’m no longer convinced I need to publish to WU with my newest station, especially for that price. I think I’m happy with publishing to my own site, WeatherCloud, and PWSWeather.

It’s worth noting that you can’t publish to MyAcurite with a RPi either. You need an Access to do that as well.

However, you can configure Weewx to upload data to other sites, like WeatherCloud, PWSWeather, and others.

There is a built-in section on the Weewx config file for PWSWeather, but not WeatherCloud. You will need to add it using the third-party Weewx extension.

Open Terminal, and use the following commands:

sudo wget http://lancet.mit.edu/mwall/projects/weather/releases/weewx-wcloud-0.11.tgz

sudo wee_extension --install weewx-wcloud-0.11.tgz

Now open the Weewx config file, as detailed on the Weewx page of this guide, change “enabled=false” to “enabled=true”, and enter your Station ID and Key, save the changes, and restart Weewx. Then wait a few minutes, and check your WeatherCloud page to see if it updates.

Although I haven’t personally used other brands of weather stations (yet), I’ve been told that some support uploading data to WU and other sites as well.


From Beginning: An Introduction – Part 1

Previous: Automatically Publish Current Conditions to a Twitter Account – Part 8

Automatically Publish Current Conditions to a Twitter Account – Part 8

Previous: Download and Install Weewx – Part 7

From the Beginning: An Introduction – Part 1

Publishing current conditions to a Twitter account certainly isn’t required. Weewx and your Meteotemplate website will continue to work just fine. If you’re happy with that, that’s fine. You can stop here. You’re done. Congratulations!!!

If you do want to publish updates to Twitter, read on…

This image has an empty alt attribute; its file name is current_conditions_twitter-1024x580.png

It took a lot of research and trial and error, but I finally figured out how to publish current conditions from my weather station(s) to Twitter. I’ll spare you the details of what didn’t work the way I wanted it to, and skip to what did work.

This image has an empty alt attribute; its file name is weewx_rss_feed.png

You can find your Weewx website’s RSS feed by going to your Weewx website. Copy/paste it somewhere safe and save it. You’ll be using it, but replacing the local IP address part with your external IP.

If you want to control what details appear in your RSS feed, and thus your Twitter feed, you’ll need to edit the weewx_rss.xml.tmpl file.

This image has an empty alt attribute; its file name is RPI_edit_weewx_rss_xml_tmpl-1024x768.png

I strongly recommend creating a backup of the Weewx RSS file. You can find it by looking in the folder (not using Terminal) found in the following command To edit the Weewx RSS file, type (please note all commands are case sensitive):

sudo nano /etc/weewx/skins/Standard/RSS/weewx_rss.xml.tmpl (and press enter)

If at any point you make a mistake or want to start over, DO NOT SAVE the file. Press CTRL+X, N (for no), and enter. Then reopen the RSS file.

What you see in the image above is not what the original file looks like.

Click the image to view it full-size, and change the file so it looks like what you see in the image.

Then, in that file, scroll down a bit. You need to change the section between <p> and </p>. It’s very similar to the other section, but slightly different. Time, Temp, Wind Chill, Heat Index, etc. Feel free to *carefully* copy/paste (using ‘paste’ in the Edit menu). It will paste to wherever the cursor is. Do NOT use CTRL+C and CTRL+V.

Time: $current.dateTime<br/>
Temp: $current.outTemp<br/>
Wind Chill: $current.windchill<br/>
Heat Index: $current.heatindex<br/>
Dewpoint: $current.dewpoint<br/>
Humidity: $current.outHumidity<br/>
Barometer: $current.barometer<br/>
Wind: $current.windSpeed from $current.windDir.ordinal_compass<br/>
Max Wind Gust this hour: $span($hour_delta=1).windGust.max<br/>
Rain Rate: $current.rainRate<br/>

When you’re done, it should look like this:

When you’re done editing the file, press CTRL+X, then Y (yes), and press enter, and it will save and close the file. While still in Terminal, for good measure, restart Weewx or simply reboot (sudo reboot):

sudo /etc/init.d/weewx restart

Changes may not take effect immediately, so on to the next step while you wait…

This image has an empty alt attribute; its file name is dlvr_it_pro_plan-1024x524.png

I tried a few different services that publish RSS feed items to Twitter, including IFTTT, Zapier, and finally found my ideal solution with dlvr.it. Many IFTTT “applets” will do the job, but IFTTT is free, and is limited to 100 posts per day, which may be adequate depending on how often you set Weewx to update. Zapier also does the job, but I found their setup too complicated and their pricing too expensive ($250/year), and they only post a max of 250 tweets per day.

Then I checked out dlvr.it. It’s $99 USD per year, allows unlimited posts to Twitter per day, and plays nice with the Weewx RSS feed. Nothing complicated about it, either.

Why would I want unlimited posts to Twitter, you may ask? Twitter’s own daily tweet daily limit is 2,500. No one will read or care about all those posts, we can all agree on that. Twitter is about real-time updates, and my weather stations and Weewx is setup to update every 5 minutes, because weather conditions can change quickly at times. People generally don’t care what the weather was like 5 minutes ago, they want to know what it’s like right now, so past tweets don’t matter a lot. Not a lot of people subscribe to my weather stations’ Twitter updates, and that’s fine, but those that do appreciate it, and so do I, as I always have Tweetdeck open. Regardless, it’s been part of a fun project for me.

This image has an empty alt attribute; its file name is dlvr_it_leducweather1-1024x466.png

Once you’ve subscribed to the Pro plan, and after you’ve created a Twitter account and linked it to your dlvr.it account, create a new “feed”. On the ‘Detail’ tab, copy/paste your Weewx’s RSS feed address (using the external IP).

This image has an empty alt attribute; its file name is dlvr_it_leducweather2.png

On the ‘Updates’ tab, you can choose the frequently of how often dlvr.it checks the RSS feed for new items.

Weewx sends out more than just current conditions in each RSS feed update, so choose ‘1’ max update per post to just grab the current conditions part.

Don’t worry about the ‘Max posts per day’ field. I asked about that. They said they allow unlimited posts per day up to Twitter’s own limit, and couldn’t explain why that field is there.

This image has an empty alt attribute; its file name is dlvr_it_leducweather3.png

On the ‘Advanced’ tab, choose ‘Prefer Full Content’ under ‘Body Posting Options’.

This image has an empty alt attribute; its file name is dlvr_it_leducweather4-1024x410.png

Click the feed your want to modify, and click the Settings ‘gear’ icon.

This image has an empty alt attribute; its file name is dlvr_it_leducweather_output_no_url.png

On the ‘Settings’ page, under ‘Post Options’, turn off ‘Post Title’, turn on ‘Post Body’, and turn off ‘Post Url’. These will ensure that only the current conditions are posted as Twitter updates, and nothing else.

That’s it, it should pull from the Weewx RSS feed and start posting shortly. If it doesn’t, you’ll have to investigate what’s happening. Everything I’ve described has worked for me, so hopefully it works for you. If it does, once again, you’re awesome, congratulations!!!

Once you have everything working the way you want it to, I *strongly* recommend creating a system image of your RPi’s MicroSD card using Win32 Disk Imager (free) using this very handy guide from the Pi Hut, and put the image somewhere safe. At least once a month, I recommend connecting to your RPi and doing updates via Terminal (sudo apt-get update, sudo apt-get upgrade), and restarting to ensure your RPi continues working smoothly.

You can find my weather stations websites, Facebook pages, and Twitter accounts here.

Side note: please do NOT reach out to me for any kind of technical support or help regarding this guide. Though you’re welcome to connect with me in general via email or on Twitter via my Contact page. I will not be held responsible for any actions you take during your own weather station website project setup. My only advice is to backup any files before you make changes, and be very careful and deliberate when making those changes. Best of luck to you!

Previous: Download and Install Weewx – Part 7

Next: Publishing Weather Station Data to Third Party Websits – Part 9

From the Beginning: An Introduction – Part 1

Download and Install Weewx – Part 7

From the Beginning: An Introduction – Part 1

Previous: Download and Setup Meteotemplate – Part 6

According to the Weewx website: “WeeWX is a free, open source, software program, written in Python, which interacts with your weather station to produce graphs, reports, and HTML pages. It can optionally publish to weather sites or web servers.”

This image has an empty alt attribute; its file name is Screenshot-2018-12-19-15.57.05-1024x576.png

You’ll be installing and configuring Weewx on your RPi, which will communicate and publish information to your Meteotemplate website, as well as Weather Underground, etc, should you decide to do so. Using Terminal on your RPi, follow the instructions on the Weewx website to download and install Weewx on your Raspberry Pi (using Terminal).

However, I have found not adding “sudo” (w/o quotes) before each command sometimes means they don’t work. So I recommend adding “sudo” before each command.

In Terminal (press enter after each command):

sudo wget -qO - http://weewx.com/keys.html | sudo apt-key add -
 
sudo wget -qO - http://weewx.com/apt/weewx.list | sudo tee /etc/apt/sources.list.d/weewx.list [note: this command should be entered on a single line]
 
sudo apt-get update
 
sudo apt-get install weewx

In some cases, I get the message “Permission denied” even when using “sudo”. If that happens, switch to being the ‘root’ user. For example:

sudo su (then press enter)

Then type your command, pressing enter after each one. When done, type ‘exit’ and press enter to leave ‘root’ user mode.

Meteotemplate Extension for Weewx

Download and install the third-party Meteotemplate extension (add-on) for Weewx on your Raspberry Pi. This will allow Weewx to communicate with your Meteotemplate website.

This image has an empty alt attribute; its file name is unnamed.jpg

1. Download the extension. Open Terminal and type (please note the commands are case sensitive):

sudo wget -O weewx-meteotemplate.zip https://github.com/matthewwall/weewx-meteotemplate/archive/master.zip

OR download it from my Dropbox:

sudo wget -O weewx-meteotemplate.zip https://www.dropbox.com/s/eptdcmyzlywrdbw/weewx-meteotemplate.zip?dl=0

2) run the installer:

sudo wee_extension --install weewx-meteotemplate.zip

3) In Terminal, open Weewx using the following command:

sudo nano /etc/weewx/weewx.conf

This image has an empty alt attribute; its file name is 31114557427_99ee799136_b-1024x768-1024x768.jpg

4) enter (copy/paste via the ‘edit’ menu in Terminal) the following information parameters (“server_url” and “password” – your Meteotemplate admin password) in weewx.conf:

[StdRESTful]

[[Meteotemplate]]

server_url = http://yourwebsite.com/Meteotemplate/api.php

password = your Meteotemplate Admin password

This image has an empty alt attribute; its file name is RPi-sudo_nano_weewx_conf3-1024x768-1024x768.png

Your server url will be where the ‘api.php’ file is located. If you’re not sure, login to your server using an FTP client (such as FileZilla) and find it that way, paying close attention to the server directory file path.

5) Now, save and exit weewx.conf by pressing CTRL+X, Y, and enter.

6) restart weewx:

sudo /etc/init.d/weewx restart

Now, after all that hard work, you’ll want to view your Weewx website on your Raspberry Pi. To do this, you will need to do two things:

Install the NGINX Web Server:

Install the NGINX web server according to this guide.

NGINX allows weewx info to be presented on a web page. Scroll down to step 9 on that page if you haven’t installed the Apache web server. If you’re strictly following this guide, you haven’t installed Apache.

For the sake of convenience, and to completely document this process, here are the steps:

Open Terminal, and use the following commands:

sudo apt install nginx php-fpm
sudo nano /etc/nginx/sites-available/default

Look for the line:

index index.html index.htm index.nginx-debian.html;

Replace it by the line:

index index.html index.htm index.php;

We will now activate php-fpm for Nginx. To do this, look for the lines:

#location ~ \.php$ { 
# include snippets/fastcgi-php.conf; 
#
# # With php5-cgi alone: 
# fastcgi_pass 127.0.0.1:9000; 
# # With php5-fpm: 
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#}

Modify that to look this this:

location ~ \.php$ { 
include snippets/fastcgi-php.conf;
 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

We’re done with making changes to that file. Press CTRL+X, Y, and enter to exit the file and go back to Terminal.

Now we need to change some permissions so everything plays nicely with each other:

sudo chown -R www-data:pi /var/www/html/ 
sudo chmod -R 770 /var/www/html/

Now we need to add an “index.php” file to verify that PHP is working (if you get a “permission denied’ message, switch to “sudo su” (root user) and try the command again):

sudo echo "<?php phpinfo(); ?>" > /var/www/html/index.php

Now we need to restart the NGINX web server:

sudo /etc/init.d/nginx restart

Follow ALL of the instructions on that web page, including the ‘403 Forbidden’ section. You may or may not encounter this error (I have with each of my RPi Weewx/NGINX installs). No harm in doing those steps anyway, as it ensures proper permissions.

Forward Port 80 (HTTP) On Your Router/Modem:

To allow access on your local network and via the internet to Weewx on your Raspberry Pi, you MUST forward port 80 to your RPi’s local IP address (something easily done on most routers), access your router’s home page (usually something like: 192.168.0.1), and enter your credentials. If you’re not sure, ask whoever manages it for you to forward the port for you, or if it hasn’t been modified since you got the router/modem, there should be a label on it with the details.

This image has an empty alt attribute; its file name is router_port_forwarding-1024x425.png

Find the Port Forwarding section, and create a new ‘rule’, forwarding port 80 to your Raspberry Pi’s local IP address as shown above. (if unsure, type “ifconfig” without the quotes in Terminal), as shown above. The IP address will obviously be different. After that, save changes and log out of your router/modem.

Give it a few minutes, and hopefully the next time you visit your RPi’s local IP address with “/Weewx” (http://192.168.0.XX/weewx), or using your external IP address (type “what is my ip” in Google to find it), and add “/weewx”. Hopefully you’ll see your Weewx website! If not, you’ll have to investigate to find out what’s going on.

“403 forbidden” NGINX Error

If you encounter a “403 forbidden” error from NGINX, enter these commands in Terminal (again, full credit to HowToRaspberryPi.com):

Use “sudo” at the beginning of each command if you need to, or switch to root user, as described above.

sudo echo 'Nginx work’s !' > /var/www/html/index.html
sudo chown www-data:www-data /var/www
sudo chmod 744 /var/www

That’s it. You’re done. For good measure, reboot your Raspberry Pi (sudo reboot) and wait 10-15 minutes before trying to access the web page again. Refresh the page a couple of times to ensure you’re viewing the latest version.

Changing the Theme of the Weewx Web Page:

Sometime late in 2018 or early 2019, the developers of Weewx released a new version that change the default theme the Weewx uses for web page display. This also affected the RSS feed, meaning that the URL used for the “Standard” theme no longer worked, and if you setup a service like dlvr.it to tweet current conditions (covered on the next page of this guide), that was now broken. Presumably, you could just change the url path to the new path for dlvr.it to use it, but that didn’t work in my case. Not sure why.

Personally, I prefer the “Standard” theme compared to the “Seasons” theme, and thankfully it’s an easy fix to switch back to the “Standard” theme. Open the “weewx.conf” file again and do the following:

In the [StdReport] section, under [[SeasonsReport]], change “enable = true” to “enable = false”, and under [[StandardReport]], change “enable = false” to “enable = true”

Now, save and exit weewx.conf by pressing CTRL+X, Y, and enter.

That will also fix the URL path to the RSS feed back to the way it was, to dlvr.it will tweet current conditions again.

Then, restart for good measure:

sudo reboot

Previous: Download and Setup Meteotemplate – Part 6

Next: Automatically Publish Current Conditions to a Twitter Account – Part 8

From the Beginning: An Introduction – Part 1

Download and Setup Meteotemplate – Part 6

IMPORTANT NOTE: This post series is currently a work in progress.

From the Beginning: An Introduction – Part 1

Previous: Download and Install Firefox – Part 4

This image has an empty alt attribute; its file name is meteotemplate_website1-1024x577-1024x577.png

On your computer (not your Raspberry Pi), go to Meteotemplate.com and click on ‘Download’ at the top of the page.

This image has an empty alt attribute; its file name is meteotemplate_website2-1024x579-1024x579.png

To download the files, you will need to request a ‘token’, which will then allow you to download the files.

This image has an empty alt attribute; its file name is meteotemplate_website3-1024x577-1024x577.png

Not sure why this tedious step is necessary and why they can’t just let you download the files without requesting them first, but they don’t. You will now need to wait up to 24 hours (or more) to receive an email with the token to download the files.

Once you have downloaded the Meteotemplate files to your computer, extract them. Using FileZilla, create a Meteotemplate folder on your server, and upload the files there. It’s going to take a few minutes. If you’re unsure of how to setup FileZilla to communicate via FTP with your account with your hosting provider, you will once again need to reach out to your web host provider for help or their support team.

This image has an empty alt attribute; its file name is meteotemplate_main_setup-1024x578-1024x578.png

Once the files are uploaded, use FileZilla to find where your “setup.php” file is located, and navigate to that address in a browser to configure Weewx. Instructions can be found on the Weewx Wiki.

This image has an empty alt attribute; its file name is meteotemplate_lock.png

Once you have Meteotemplate configured, navigate to your Meteotemplate website in your browser, i.e.: www.comoxweather.ca/Meteotemplate, click the “lock” icon on the bottom right of the page to access to the login page. Fill in your info, and you’ll see the Control Panel.

It won’t show up as “online” until you configure it to communicate with Weewx, as described on the next step of this guide.

This image has an empty alt attribute; its file name is meteotemplate_control_panel-1024x579-1024x579.png

Many of the features you can see on Meteotemplate websites, such as mine, are thanks to the free Blocks and Plugins, found on the Meteotemplate website. You can download them, and upload them to your website via FTP (FileZilla).

This image has an empty alt attribute; its file name is meteotemplate_setup_blocks-1024x552.png

On the ‘Setup’ page via the Control Panel, to arrange which Blocks appear on your website and where they appear, simply type in the name (case sensitive) of each block, press enter, and add the next block, and so on. For Plugins, click the ‘Menu’ icon in the Control Panel and manage which Plugins appear and where they appear. It’s pretty straightforward once you see how the included plugins are already done.

Previous: How to Create Your Own Weather Station Website – Part 5

Next: Download and and Install Weewx – Part 7

From the Beginning: An Introduction – Part 1