martyp
Posts: 41
Joined: Thu Oct 03, 2013 10:07 pm

Re: Setting up pywws / writing data to website

Sun Apr 06, 2014 4:31 pm

Hi all,

I'm having the same difficulties getting this working, any help would be greatly appreciated.

I even tried the template on my PC, accessing it with the web browser with all the png etc. files copied to the folder in the same directory structure. Viewing the php file on my PC locally it showed the whole page which led me to think it's a permissions issue on the Pi where the template is unable to access the images etc. to display them?
I'm also missing many of the png and txt files it seems.
I'm using the image from www.dragontail.co.uk.
I edited the weather.ini file as well to try and get it right. I also have a slightly different set up as I have a link from the var/www folder to the webdata folder and have the index.php file in the webdata folder instead of the var/www folder.

It loads ok as www.website.co.uk/webdata/index.php
The data in the webdata folder is updating fine but is missing many of the files. The weather.ini file is below:
[config]
ws type = 1080
day end hour = 24
gnuplot encoding = iso_8859_1
language = en
logdata sync = 1
rain day threshold = 0.2
usb activity margin = 3.0
pressure offset = 26.7
template encoding = iso-8859-1
gnuplot version = 4.2

[fixed]
pressure offset = -7.1

[paths]
templates = /home/pi/weather/text
graph_templates = /home/pi/weather/plot
work =
local_files = /home/pi/weather/results/

[live]
services = []
twitter = []
text = []
plot = []

[logged]
last update =
plot = ['rose_1hr.png.xml', 'rose_12hrs.png.xml']
text = ['1hrs.txt', '6hrs.txt', '6hrs_html_cp.txt', 'forecast_icon.txt']
twitter = []
services = []

[hourly]
last update =
plot = ['24hrs_full_features.png.xml', '24hrs.png.xml', 'rose_24hrs.png.xml']
text = ['feed_hourly.xml', '24hrs.txt']
twitter = []
services = []

[12 hourly]
last update =
plot = []
text = []
twitter = []
services = []

[daily]
last update =
plot = ['7days.png.xml', '2012.png.xml', '28days.png.xml', 'rose_7days_nights.png.xml']
text = ['feed_daily.xml', 'forecast_week.txt', '7days.txt', 'allmonths.txt']
twitter = []
services = []

[ftp]
local site = True
secure = False
site = ftp.your_isp.co.uk
user = username
password = userpassword
directory = /home/pi/webdata

[Zambretti]
north = True
baro upper = 1050.0
baro lower = 950.0

The weather log now shows:
17:25:47:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 108, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 105, in main
return Hourly(args[0])
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 78, in Hourly
hourly_data, daily_data, monthly_data).do_tasks():
File "/usr/local/lib/python2.7/dist-packages/pywws/Tasks.py", line 70, in __init__
self.daily_data, self.monthly_data, self.work_dir)
File "/usr/local/lib/python2.7/dist-packages/pywws/Plot.py", line 476, in __init__
os.makedirs(self.work_dir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''

User avatar
pingu512
Posts: 64
Joined: Sun Apr 01, 2012 2:39 pm
Location: Chester
Contact: Website

Re: Setting up pywws / writing data to website

Wed Apr 09, 2014 8:16 pm

Hi Marty
Looks like something cannot write to directory. Check that all the paths in the ini file exist and can be written to.
The entry for work =
should be a directory that exists
I then use http://www.freevirtualservers.com/free- ... oid=1018_1 to host the site which supports php

http://www.weather.dragontail.co.uk

Phil GU0SUP
Posts: 3
Joined: Sun May 18, 2014 2:14 pm

A problem with Twitter

Sun May 18, 2014 4:44 pm

Hi all,

Until some time this afternoon, my weather station (a Maplins N96GY) was happily Tweeting the weather every hour.
I am not sure what I have done, but when I look at the Weather.Log, it is now showing this:

IOError: pywws.device_cython_hidapi.USBDevice.read_data failed
15:05:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
15:15:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
15:25:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
15:35:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
15:45:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
15:55:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
16:05:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
16:15:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 108, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 105, in main
return Hourly(args[0])
File "/usr/local/lib/python2.7/dist-packages/pywws/Hourly.py", line 72, in Hourly
DataLogger(params, status, raw_data).log_data()
File "/usr/local/lib/python2.7/dist-packages/pywws/LogData.py", line 174, in log_data
for data, last_ptr, logged in self.ws.live_data(logged_only=(sync > 1)):
File "/usr/local/lib/python2.7/dist-packages/pywws/WeatherStation.py", line 393, in live_data
new_data = self.get_data(old_ptr, unbuffered=True)
File "/usr/local/lib/python2.7/dist-packages/pywws/WeatherStation.py", line 547, in get_data
return _decode(self.get_raw_data(ptr, unbuffered),
File "/usr/local/lib/python2.7/dist-packages/pywws/WeatherStation.py", line 538, in get_raw_data
self._data_block = self._read_block(self._data_pos)
File "/usr/local/lib/python2.7/dist-packages/pywws/WeatherStation.py", line 614, in _read_block
new_block = self.cusb.read_block(ptr)
File "/usr/local/lib/python2.7/dist-packages/pywws/WeatherStation.py", line 267, in read_block
if not self.dev.write_data(buf):
File "/usr/local/lib/python2.7/dist-packages/pywws/device_cython_hidapi.py", line 157, in write_data
'pywws.device_cython_hidapi.USBDevice.write_data failed')
IOError: pywws.device_cython_hidapi.USBDevice.write_data failed
16:35:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
16:45:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
16:55:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
17:05:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
17:15:20:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}
17:25:44:pywws.weather_station:status {'unknown': 0, 'lost_connection': 0, 'rain_overflow': 0}

My Weather.ini file looks like this:
[config]
ws type = 1080
day end hour = 9
gnuplot encoding = iso_8859_1
language = en
logdata sync = 1
rain day threshold = 0.2
usb activity margin = 3.0
pressure offset = -12.4
template encoding = iso-8859-1
gnuplot version = 4.2

[fixed]
pressure offset = -7.1

[paths]
templates = /home/pi/weather/templates/
graph_templates = /home/pi/weather/templates/
work = /home/pi/weather/temp
local_files = /home/pi/weather/results/

[live]
services = []
twitter = []
text = []
plot = []

[logged]
services = []
twitter = []
text = ['6hrs.txt']
plot = []
yowindow =

[hourly]
services = []
twitter = []
text = ['24hrs.txt', '7days.txt', 'feed_hourly.xml', 'allmonths.txt']
plot = ['7days.png.xml', '24hrs.png.xml', 'rose_24hrs.png.xml' ,'24hrs_full_features.png.xml']
yowindow =

[12 hourly]
services = []
twitter = []
services = []
plot = ['7days.png.xml', '24hrs.png.xml', 'rose_12hrs.png.xml']
text = [('tweet.txt', 'T'), '24hrs.txt', '6hrs.txt', '7days.txt']
yowindow =

[daily]
services = []
twitter = []
text = ['feed_daily.xml']
plot = ['28days.png.xml']
yowindow =

[ftp]
local site = True
secure = False
site = ftp.your_isp.co.uk
user = username
password = userpassword
directory = /home/pi/webdata

[Zambretti]
north = True
baro upper = 1050.0
baro lower = 950.0

[twitter]
key = xxxxxxxx
secret = xxxxxxxxxx
latitude = 49.477
longitude = -2.578

If I type python -m pywws.TestWeatherStation
I get the block of hex data, so the Pi can clearly see the weather station.

What have I done wrong? Any help would be appreciated!

Phil Cooper
Guernsey

User avatar
DougieLawson
Posts: 37742
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Setting up pywws / writing data to website

Sun May 18, 2014 5:26 pm

Looks like your USB controller/HUB has thrown a sickie.

Could be lack of volts/amps (but probably not if it was working reliably). Could be due to a stray neutrino (this is part of my theory of all inexplicable software errors). Could be a bug in the USB drivers in the RPi firmware. Could be a bug in your pywws library.

The first and third are easier to fix with a powered hub running 5V @ plenty of amps and with sudo apt-get install rpi-update && sudo rpi-update && sudo reboot

The possible bug in pywws is probably better reported on a pywws forum.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Phil GU0SUP
Posts: 3
Joined: Sun May 18, 2014 2:14 pm

Re: Setting up pywws / writing data to website

Sun May 18, 2014 6:39 pm

Thanks for that Dougie,

As soon as I get a minute, I will try another hub. Oddly, the USB keyboard and WiFi dongle are both working fine through the hub.

Maybe it is time to image a new SD card and start again..........

Thanks

Phil Cooper
Guernsey

User avatar
DougieLawson
Posts: 37742
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Setting up pywws / writing data to website

Sun May 18, 2014 6:43 pm

I'd go with the rpi-update and reboot. That seems to be the most plausible cause for the error.

I assume you're running the latest and greatest pywws from http://jim-easterbrook.github.io/pywws/ ... index.html with current versions of all of the python dependencies that it needs.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Phil GU0SUP
Posts: 3
Joined: Sun May 18, 2014 2:14 pm

Re: Setting up pywws / writing data to website

Mon May 19, 2014 6:42 am

Dougie and the group,

Last night, just out of curiosity, I plugged the weather station directly into the Pi, rather than the hub, and it is all now working again.

I had thought the hub would be OK, as it has been working for weeks now, but it clearly isn't quite good enough.
And yes, it is an unpowered hub, but it was working, and I had seen several suggestions that this was OK. I was obviously wrong on that score.

On the hub now, I only have the WiFi adaptor and USB dongle for the integrated keyboard/mouse.

I'm very new to all this, so wasn't quite sure what the problem might be, but you pointed me in the right direction! Thanks!

My next step is to get the weather station to only Tweet every 4 or 6 hours, instead of hourly.
I actually have the weather.ini file set to 12 hours, but something is making it send hourly, and as yet, I can't see what.

It's a steep learning curve, that's for sure!

Regards

Phil Cooper
Guernsey

User avatar
DougieLawson
Posts: 37742
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Setting up pywws / writing data to website

Mon May 19, 2014 7:27 am

Wireless keyboards tend to be very power hungry. The rules for keyboards and mice is cheaper and crapper the better. My wired keyboard cost less than a tenner. My wired, optical mouse was found in the back of the equipment cupboard.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Beginners”