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:
#!/bin/bash cd /usr/local/weather python Hourly.py -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
- 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.
- 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):
[ftp] secure = False site = ftp.example.com local site = False user = myaccount@example.com 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 maidstoneweather.com – although the uploaded templates only form part of that site.
Newbie question but how do I set this to use the “local” apache rpi
site = ????
local site = true ??
From the docs: http://pywws.googlecode.com/svn/trunk/doc/html/guides/weather_ini.html#ftp-configuration-of-uploading-to-a-website
To do a local site add the following:
local site=true
directory=/vaw/www/weather
the main bit is directory= which should point to your local site. IIRC this also disables ftp.
Reblogged this on Gigable – Tech Blog.
Do you think it would be possible to run this on a remote hillside with a battery, solar panel and 3G dongle?
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.
Thank you so much for your posts here. I’d never have got up my weather station & pi up and running without them.
http://jasonfarmer.co.uk … although it still needs prettyfying …
[...] 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 [...]
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.
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.
[...] 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 [...]
Hello , im comming from holland , end enjoy your project , how i can run pywws conversions , end add to witch map ? greets fer ,
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.
Sorry i know how te edit the file now i need to change from mph to kmh , but how ?
I’m not certain as I use the defaults but quickly browsing the pywws google group shows that some people are doing it.
Where are you trying to do this conversion? If in the code theres conversions.py which handles all sorts of conversions
http://pywws.googlecode.com/svn/trunk/doc/html/api/pywws.conversions.html