Installing a USB Weather Station on a Raspberry PI part 2

In the first article I covered how to install a weather station on a Raspberry PI. In the second part I’ll cover how to get it to upload data on an hourly basis to a website using FTP.

Getting the station to run hourly

First we need to get the station to run hourly. To do this I created a script called weatherupload which I placed under /usr/local/bin

pi@kell: ~$ sudo vi /usr/local/bin/weatherupload

Enter the following:

cd /usr/local/weather
python -vvv data

Once saved make it executable and then edit the main crontab:

pi@kell: ~$ sudo chmod +x /usr/local/bin/weatherupload
pi@kell: ~$ sudo vi /etc/crontab

At the end of the file you need to add the following:

0 * * * * root /usr/local/bin/weatherupload

Save it and now every hour it will now run.

Note: I’ve placed it there and not under /etc/cron.hourly because

  1. cron.hourly runs once an hour, but not necessarily at the top of the hour. I a later article when I add twitter you want the tweet to be close to 0m rather than at a random time.
  2. I’ve found in the past that using crontab -e doesn’t always work, even for root but in the core crontab it just works

Uploading to a website

First to generate the graphs pywws uses gnuplot so we need to install it:

pi@kell: ~/sudo apt-get install gnuplot

Next we need to add some details to the stations weather.ini file. At the top theres a section called paths. Make sure those point to the relevant templates and graph_templates directories in your pywws install.
Next under the hourly section you should see a pair of lines:

plot = []
text = []

You need to add the plots and pages that need to be generated:

plot = ['7days.png.xml', '24hrs.png.xml', 'rose_24hrs.png.xml', 'rose_7days_nights.png.xml']
text = ['current.html', '24hrs.html', '6hrs.html', '7days.html', 'feed_hourly.xml', 'allmonths.html']

Finally theres the ftp section which needs configuring with the remote ftp server (your web host will give you these):

secure = False
site =
local site = False
user =
directory = /weather/
password = mypassword

That’s about it. Now when you run the hourly script it will generate some simple pages & images to your website.

You can see an example of this over at – although the uploaded templates only form part of that site.

27 thoughts on “Installing a USB Weather Station on a Raspberry PI part 2

  1. Dave says:

    Newbie question but how do I set this to use the “local” apache rpi
    site = ????
    local site = true ??

  2. Billy says:

    Do you think it would be possible to run this on a remote hillside with a battery, solar panel and 3G dongle?

    • petermount1 says:

      In theory it should be. Your main issue will be power, primarily the Pi itself and the 3G dongle.

      The station uses AA batteries for the instrumentation & the base station but they do last. I should replace mine at some point as it’s almost 2 years on the original batteries. Tip: the base station uses usb power when connected & switches to its own batteries when usb power is lost. Also for some of the higher end stations they have an option of the instrumentation to recharge with a solar panel on top – should be an easy conversion.

      As for the Pi, it uses just above 700mA for itself and although I don’t know what a typical 3g dongle uses when I used to use one on a netbook it did cause the battery to drain. More so if in a weak 3g area.

      Saying that as there are custom weather stations available with on board 3g it must be solvable – perhaps if a dongle is causing power consumption issues then a dedicated 3g/gprs module might be better as they tend to have a low power mode. I’ve seen some on farnel from £38, similar on Ebay.

      So in short: yes it should be doable, you just need to ensure you have enough power from the solar panels to supply the pi & 3g.

  3. slowtarget says:

    Thank you so much for your posts here. I’d never have got up my weather station & pi up and running without them. … although it still needs prettyfying …

  4. […] his blog, Peter Mount explains the necessary raspian changes and in the 2nd part he also covers uploading the data online and later he’ll cover […]

  5. Mike Mazz says:

    Peter this is really nice application for the Rpi. I’m going to replace the scripts you wrote above with my automation solution that can run on the Rpi now. It’s certainly a bit overkill for this project but it allows me to demonstrate how we can build significant process workflows across embedded devices or the like. E.g., Rpi.

    • petermount1 says:

      It’ll be interesting to hear how you get on. The RPI should cope, its surprising how they cope – the weather station was originally on a full sized Linux box (before it died) & the RPI has just worked with less maintenance.

      In fact the only major thing I’ve done to it was to enable SNMP.

  6. […] PYWSS állítólag működik is. Az USB konfigurációját és az adatok webszerverre postolását a fenti leírás második részében találjátok. Kell hozzá néhány library telepítés és egy pywws nevű Python script […]

  7. Fer says:

    Hello , im comming from holland , end enjoy your project , how i can run pywws conversions , end add to witch map ? greets fer ,

    • petermount1 says:

      Sorry for late reply. Which map are you trying to add to?

      Looking at the templates the ycalc element is a python expression so you should be able to just call the conversions functions in there. Not tried it myself but thats the theory.

  8. Fer says:

    Sorry i know how te edit the file now i need to change from mph to kmh , but how ?

  9. One problem with the weather.ini… I don’t have it! Where can I get it/Where can I create it?!

    Please help! I need a weather station for a deadline of Wednesday!

    • petermount1 says:

      Sorry for the late reply, the day job’s been getting in the way.

      weather.ini usually goes into your stations data directory. Once there you just put in the basic config then it will fill in the rest.

    • ckblackm says:

      create /data/weather.
      use this command ‘python pywws/ /data/weather’

      That will create your weather.ini file.

  10. Marko says:

    Hello, verry nice Tutorial, thank you verry much for it …

    i’ve found the .ini file in /user/local/weather/data and edited it as shown above,

  11. Jose Gouveia says:

    Hello, I am novice here.. and sure don’t understand much of python nor other raspberry language. I am just following your tutorial step by step to get it done.

    Now, to reach what I want, I need to ask you two questions:

    Is it possible to upload to my website just the values of the weather station in a .txt or .shtml file so then my php functions deal with them as raw info? Like in strings or something?

    If so, how do I directly upload it by ftp in raspberry? I already arranged username and password to this situation.


  12. mattadlard says:

    Would liek to see it integrated with the OpenMap Weather group as this is what they are and also helps to link each other together.

  13. Matt says:

    Hello, very good tutorial. If i want to send the data upto where i have my weather station registered. What and where do i place my settings on the pi. To get the data upto the website via a pc i have to input the weather station ID and the Password in the program that came with the station for the PC. (EasyWeather).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: