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 …
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.
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
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!
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.
Could you please be a little more detailed?
What is stations data directory?
How do I put in the basic config?
create /data/weather.
use this command ‘python pywws/LogData.py /data/weather’
That will create your weather.ini file.
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,
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.
Regards
Reblogged this on adlardmatthew.
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. http://openweathermap.org/stations
pywws already supports openweathermap – I’ve been posting to it for several years now.
Thanks for that didn’t realise, still working way through the many systems and ideas behind this scheme.
Hello, very good tutorial. If i want to send the data upto http://www.underground.com 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).
There’s a section in weather.ini where you need to put the staton ID etc
Hello, Cheers will look for that section