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:
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):
secure = False
site = ftp.example.com
local site = False
user = firstname.lastname@example.org
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.