Search

Recent Posts

Tags


« | Main | »

Linux (Fedora), pywws and WS-1090 Ambient Weather Station

By Dale Reagan | November 7, 2011

Configuring USB weather hardware (Ambient Weather WS-1090) with Fedora (Redhat Linux, FC13 at this time.)

I did my initial HW testing with a Windows system.  While there is software to create nicely formatted weather web pages I would prefer an all Linux solution so I start hunting and locate pywws (Python software for USB Wireless Weather Stations.)  A brief description from the pywws project site:

“The software has been developed to run in a low power, low memory environment such as a router. It can be used to create graphs and web pages showing recent weather readings, typically updated every hour.

Unlike some other weather station software, no “live” weather displays are produced. The software relies entirely on the weather station’s memory. This has the advantage that computer downtime (of less than two weeks or so) does not result in missing data.”

Ok, I just want to use Linux directly to fetch data from the weather console – but this does have potential as a ‘small systems’ project – we’ll see…  Side note – I was not successful using x86_64 Linux (Fedora, FC 15) for this project – I will guess that there are some lower-level machine specific features that are currently either not compatible OR that have simply not been ported yet…

Much of the remainder of this post is the output from following the pywww Getting Started page – nicely done! especially when things work so well – this is one of the best Open Source projects I have seen – it simply worked!

Note – Convention:  [user@system-name folder_name] Linux_command – the info between the brackets ‘[ ]’ is who/where and the Linux_command is what I typed; the command output is immediately below the command line.  After the initial success I moved file to the ‘pyweather’ folder.

I install USB to WS-1090 interface cable and the system log shows:

Jun  1 20:35:08 system-name kernel: usb 4-2: new low speed USB device using ohci_hcd and address 5
Jun  1 20:35:08 system-name kernel: usb 4-2: New USB device found, idVendor=1941, idProduct=8021
Jun  1 20:35:08 system-name kernel: usb 4-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jun  1 20:35:08 system-name kernel: generic-usb 0003:1941:8021.0005: hiddev98,hidraw3: USB HID v1.00 Device [HID 1941:8021] on usb-0000:00:12.1-2/input0

I download and install software followed by quick test – seems to work.

[root@system-name pywws-11.05_r380]# python TestWeatherStation.py
0000 55 aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff 1e 47 08 58 09 00 12 00 85 00 00 0a 00 00 a0 01
0020 92 27 d0 27 00 00 00 00 00 00 01 11 06 01 20 49 41 23 a8 02 40 01 46 2d 5c 03 8c 00 a8 02 40 01
0040 f4 01 8c 00 00 0c 13 0b 00 0c 13 0b 00 70 00 00 df 00 00 00 00 c5 00 12 00 00 00 00 00 00 00 00
0060 00 00 4a 29 51 20 24 01 f8 00 80 01 e6 00 80 01 e6 00 e4 00 8c 00 e4 27 6f 27 9c 27 82 27 0a 00
0080 1f 00 76 32 72 9c 72 9c 72 9c 72 9c 00 07 01 01 12 00 07 01 01 12 03 11 06 01 06 24 07 01 01 12
00a0 22 07 01 01 12 00 11 06 01 04 46 11 06 01 13 24 11 06 01 06 34 11 06 01 13 24 11 06 01 06 34 11
00c0 06 01 12 38 07 01 01 12 07 10 05 31 22 43 07 01 01 12 00 10 05 31 22 43 11 06 01 03 45 07 01 01
00e0 12 07 07 01 01 12 07 11 06 01 17 20 11 06 01 20 49 11 06 01 20 49 11 06 01 20 49 11 06 01 20 49

Ok, works for ‘root’ – what about Joe-Weather-User?

[ws-1090@system-name pywws-11.05_r380]$ python TestWeatherStation.py
Traceback (most recent call last):
File “TestWeatherStation.py”, line 119, in <module>
sys.exit(main())
File “TestWeatherStation.py”, line 71, in main
ws = WeatherStation.weather_station(ws_type=ws_type)
File “/home/ws-1090/pyweather/pywws-11.05_r380/pywws/WeatherStation.py”, line 227, in __init__
raise IOError(“Claim interface failed”)
IOError: Claim interface failed
Exception ValueError: ValueError(‘No interface claimed’,) in <bound method weather_station.__del__ of <pywws.WeatherStation.weather_station object at 0x945292c>> ignored

Nope – I/O errors most likely due to low-level permission issues…

System log reports:

Jun  1 20:51:25 system-name python: abrt: detected unhandled Python exception in TestWeatherStation.py

Solution

  1. create a user/group specifically for this device
  2. create a custom ‘udev’ file as shown below
  3. unplug the USB connection to the WS-1090; wait-a-sec-or-two; plug it back in
  4. review system logs – should show up similar to above USB device (well, it should be the same as whatever device you have – note the idVendor and idProduct values for your device…)

[root@system-name ~]# l /etc/udev/rules.d/70-ws-1090.rules
-rw-r–r–. 1 root root 225 Jun  1 20:57 /etc/udev/rules.d/70-ws-1090.rules

[root@system-name ~]# cat /etc/udev/rules.d/70-ws-1090.rules
###### 6/1/2011
##### Ambient Weather WS-1090 home weather station
##### pywww software, libusb, pyUSB
####
#### Wiki suggests group of ‘usb’
###
SYSFS{idVendor}==”1941″, SYSFS{idProduct}==”8021″, MODE=”0660″,GROUP=”ws-1090

Another test and YEE-Ha! we have data…

[ws-1090@system-name pywws-11.05_r380]$ python TestWeatherStation.py
0000 55 aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff 1e 47 08 58 09 00 12 00 85 00 00 0a 00 00 a0 01
0020 93 27 d1 27 00 00 00 00 00 00 01 11 06 01 20 59 41 23 a8 02 40 01 46 2d 5c 03 8c 00 a8 02 40 01
0040 f4 01 8c 00 00 0c 13 0b 00 0c 13 0b 00 70 00 00 df 00 00 00 00 c5 00 12 00 00 00 00 00 00 00 00
0060 00 00 4a 29 51 20 24 01 f8 00 80 01 e6 00 80 01 e6 00 e4 00 8c 00 e4 27 6f 27 9c 27 82 27 0a 00
0080 1f 00 76 32 0f 9f 0f 9f 0f 9f 0f 9f 00 07 01 01 12 00 07 01 01 12 03 11 06 01 06 24 07 01 01 12
00a0 22 07 01 01 12 00 11 06 01 04 46 11 06 01 13 24 11 06 01 06 34 11 06 01 13 24 11 06 01 06 34 11
00c0 06 01 12 38 07 01 01 12 07 10 05 31 22 43 07 01 01 12 00 10 05 31 22 43 11 06 01 03 45 07 01 01
00e0 12 07 07 01 01 12 07 11 06 01 17 20 11 06 01 20 59 11 06 01 20 59 11 06 01 20 59 11 06 01 20 59

Ok, got data, now what?

I follow the setup process and create custom data folder and then fetch the data…

[ws-1090@system-name pyweather]$ python pywws/LogData.py -vvv ~/pyweather/DATA

21:27:58:pywws.LogData:Synchronising to weather station
21:28:38:pywws.weather_station:live_data synchronised
21:28:38:pywws.LogData:Reading time 01:28:38
21:28:38:pywws.LogData:Fetching data
21:28:39:pywws.LogData:10 records written

A set of sub-folders and files are created.

[ws-1090@system-name DATA]$ tree
.
├── raw
│   └── 2011
│       └── 2011-06
│           ├── 2011-06-01.txt
│           └── 2011-06-02.txt
└── weather.ini

The ‘weather.ini’ file (note the ‘pressure offset’ – you need to determine what it is for your location – I have NOT set it yet for my location):

[ws-1090@system-name DATA]$ cat weather.ini
[fixed]
pressure offset = -6.2

[config]
ws type = 1080
language = en_US

Initial data files are found in:

/home/ws-1090/pyweather/DATA/raw/2011/2011-06

-rw-rw-r–. 1 ws-1090 ws-1090 448 Jun  1 21:28 2011-06-01.txt
-rw-rw-r–. 1 ws-1090 ws-1090 193 Jun  1 21:28 2011-06-02.txt

[ws-1090@system-name 2011-06]$ cat 2011-06-0*

2011-06-01 20:40:00,30,47,27.8,46,34.3,1018.9,0,0,128,6662.4,0
2011-06-01 21:10:00,30,49,27.8,45,34.1,1018.6,0,0,128,7213.8,0
2011-06-01 21:40:00,30,48,27.2,48,33.6,1018.7,0,0,128,7724.7,0
2011-06-01 22:10:00,30,50,26.8,48,32.9,1018.5,0,0,128,8187.9,0
2011-06-01 22:40:00,30,52,26.6,52,31.9,1018.6,0,0,128,8655.3,0
2011-06-01 23:10:00,30,50,26.5,56,31.0,1018.8,0,0,128,9019.5,0
2011-06-01 23:40:00,30,52,26.3,62,29.5,1019.0,0,0,128,9413.7,0
2011-06-02 00:10:00,30,56,26.8,66,28.3,1019.1,0,0,128,9697.2,0
2011-06-02 00:40:00,30,50,27.1,70,27.5,1019.2,0,0,128,9879.0,0
2011-06-02 01:10:00,30,52,27.7,74,26.9,1019.2,0,0,128,10061.7,0

Ok, looks pretty simple at this point – connect table values with and output web pages, graphs, etc…  Now I ‘process’ some data and get:

[ws-1090@system-name pyweather]$  python pywws/Process.py ~/pyweather/DATA

21:40:28:pywws.Process:Generating summary data
21:40:28:pywws.Process:day: 2011-06-01 05:00:00
21:40:28:pywws.Process.Acc:2011-06-01 21:10:00 rain jump 6662.4 -> 7213.8
21:40:28:pywws.Process.Acc:2011-06-01 21:40:00 rain jump 7213.8 -> 7724.7
21:40:28:pywws.Process.Acc:2011-06-01 22:10:00 rain jump 7724.7 -> 8187.9
21:40:28:pywws.Process.Acc:2011-06-01 22:40:00 rain jump 8187.9 -> 8655.3
21:40:28:pywws.Process.Acc:2011-06-01 23:10:00 rain jump 8655.3 -> 9019.5
21:40:28:pywws.Process.Acc:2011-06-01 23:40:00 rain jump 9019.5 -> 9413.7
21:40:28:pywws.Process.Acc:2011-06-02 00:10:00 rain jump 9413.7 -> 9697.2
21:40:28:pywws.Process.Acc:2011-06-02 00:40:00 rain jump 9697.2 -> 9879.0
21:40:28:pywws.Process.Acc:2011-06-02 01:10:00 rain jump 9879.0 -> 10061.7
21:40:28:pywws.Process:month: 2011-06-01 05:00:00

Hmm, NO rain today – off to check the product web site and best I can tell, the rain gauge is quite sensitive to movement so the ‘buckets’ are tipping and ‘rain is pouring’… [This is an install/hardware issue – not a pywww issue – I need to locate the gauge at a stable location – it’s on the list…]

Ye-HA #1 – we now have some more data/files to review.

[ws-1090@system-name DATA]$ tree
.
├── daily
│   └── 2011
│       └── 2011-06-01.txt
├── hourly
│   └── 2011
│       └── 2011-06
│           ├── 2011-06-01.txt
│           └── 2011-06-02.txt
├── monthly
│   └── 2011-01-01.txt
├── raw
│   └── 2011
│       └── 2011-06
│           ├── 2011-06-01.txt
│           └── 2011-06-02.txt
└── weather.ini

[ws-1090@system-name 2011]$cd  /home/ws-1090/pyweather/DATA/daily/2011 ; l
total 4
-rw-rw-r–. 1 ws-1090 ws-1090 140 Jun  1 21:40 2011-06-01.txt

[ws-1090@system-name 2011]$ cat 2011-06-01.txt

2011-06-02 01:10:00,2011-06-01 05:00:00,31.0,,,34.3,2011-06-01 20:40:00,27.06,,,27.8,2011-06-01 20:40:00,0.0,0.0,2011-06-01 20:40:00,8,0.0

 pywws includes some sample Gnuplot scripts for generating graphs – I will probably use RRDTool instead.  I exchanged several emails  with the pywws author (again, this project features great interaction/help) as I searched for a secondary solution to collect ‘simple’ data in realtime.

Additional Weather Station Data Recording Solutions

wwsr -h
#######################################################################
# Wireless Weather Station Reader v0.1                                #
# (C) 2007 Michael Pendec                                             #
#                                                                     #
# options                                                             #
#  -h     help information                                            #
#  -p     Start at offset (can be used together with below parameters #
#  -x     Show bytes retrieved from device                            #
#  -z     Reset log buffer (will ask for confirmation.                #
#                                                                     #
#  -a     Show all stats (overrides below parameters)                 #
#  -s     Show current history position                               #
#  -t     Show temperature                                            #
#  -j     Show Pressure (hPa)                                         #
#  -u     Show humidity                                               #
#  -r     Show rain                                                   #
#  -w     Show wind                                                   #
#  -o     other                                                       #
#                                                                     #
#######################################################################
wwsr -a
#####################################################
# Reading last updated record from device           #
# Last saved values:                                #
# 224:            interval:                   5     #
# 225:            indoor humidity            47     #
# 228:            outdoor humidity           66     #
# 226 227:        indoor temperature         22.4   #
# 229 230:        outdoor temperature        20.8   #
# 233:            wind speed                  0.3   #
# 234:            wind gust                   1.0   #
# 236:            wind direction             NE     #
# 238 239:        rain?                      24.6   #
# 237:            rain - ??                  12.0   #
# 248:            rain1                     246     #
#                 rain2                     120     #
# 235:            other 1                     0     #
# 239:            other 2                     0     #
# 231 232:        pressure(hPa)            1025.9   #
#                 Current history pos:     4cb0     #
#                                                   #
# Current values:                                   #
# 240:            Since last save:            1min  #
# 241:            indoor humidity            47     #
# 244:            outdoor humidity           67     #
# 242 243:        indoor temperature         22.4   #
# 245 246:        outdoor temperature        20.8   #
# 249:            wind speed                  0.7   #
# 250:            wind gust                   1.4   #
# 252:            wind direction              N     #
# 254 255:        rain? this is always zero    24.6 #
# 253:            rain - 24h?                12.0   #
# 254:            rain1                     246     #
#                 rain2                     120     #
# 251:            other 1                     0     #
# 255:            other 2                     0     #
# 247 248:        pressure(hPa)            1026.0   #
#                 Current history pos:     151c     #
#                                                   #
#####################################################
#####################################################################
# USAGE: wslogger [-dp] | [interval [count]]                        #
#    eg, wslogger         # print human readable output             #
#        wslogger 5       # print every 5 seconds                   #
#        wslogger 1 5     # print 5 times, every 1 second           #
#        wslogger -p 60   # print every 60 seconds parseable output #
#  Fields:                                                          #
#   Time    : Current time                                          #
#   %IH     : % Indoor humidity                                     #
#   %OH     : % Outdoor humidity                                    #
#   IT°C    : Indoor temp Celsius                                  #
#   OT°C    : Outdoor temp Celsius                                 #
#   DP°C    : Outdoor dew point temp Celsius                       #
#   WC°C    : Outdoor wind chill temp Celsius                      #
#   Wm/s    : Wind speed meter/sec                                  #
#   Gust    : Wind gust meter/s                                     #
#   WD      : Wind direction                                        #
#   1hr     : Rain 1hr                                              #
#   24hr    : Rain 24hr                                             #
#   T       : Rain total                                            #
#   P       : Abs Pressure                                          #
#####################################################################
#######################################################################
wslogger.pl #(with no arguments)
     Time %IH %OH  IT°C  OT°C  DP°C  WC°C  Wm/s  Gm/s  WD  1Hr 24Hr     T      P
 11:21:10  47  65  22.5  21.0  14.2  21.0   2.7   9.1  NE  0.0  0.0 18928.8 1025.8
wslogger.pl -p #('parseable' output)
 1320682870:47:65:22.5:21.0:14.2:21.0:2.7:9.1:NE:0.0:0.0:18928.8:1025.8
#######################################################################

wslogger.pl Notes:  In addition to libusb you will need several Perl modules which can be install via ‘cpan‘ (use sudo):

  1. cpan CPAN
  2. cpan Data::Dumper
  3. cpan Carp::Assert
  4. cpan ExtUtils::MakeMaker
  5. cpan Inline::MakeMaker
  6. cpan Device::USB

In general, I am finding that tools for USB device access via Linux might be a bit easier to use if the solutions included a means to display the device information for the device being used.  I found myself using  lsusb and creating custom udev  rules in my attempt to create a solution that always works (i.e. all automated processes start without the need for manual intervention after a reboot…)

2/2012 Update – I have had several ‘lockups’ with this device:

Topics: Coastal Georgia, Computer Technology, News/Events, Web Technologies | Comments Off on Linux (Fedora), pywws and WS-1090 Ambient Weather Station

Comments are closed.


________________________________________________
YOUR GeoIP Data | Ip: 73.21.121.1
Continent: NA | Country Code: US | Country Name: United States
Region: | State/Region Name: | City:
(US only) Area Code: 0 | Postal code/Zip:
Latitude: 38.000000 | Longitude: -97.000000
Note - if using a mobile device your physical location may NOT be accurate...
________________________________________________

Georgia-USA.Com - Web Hosting for Business
____________________________________