Weather Station data logger

I recently bought a wireless Weather Station on eBay and wanted to hook it up to my web server which runs Linux.

Wireless Weather Station

Google revealed a couple of free software options (one in C, the other in Python) and a couple of useful sites, in particular Jim Easterbrook’s and Michael Pendec’s.

The Python package was overkill for my needs and I was initially planning to modify the C source but it was a bit, er, messy so I decided work on my Perl skills and write something from scratch.

You can see the graphed results in my Environmental Stats page.

You can also view it via the Weather Underground:


DownloadDescriptionVersionUploaded
wslogger.plWeather Station data logger written in perl1.412-02-2011

32 Comments

  • mrc says:

    Hello .. I would really like to try your script, but I can not download it, the link does not work.

  • Steve says:

    Ooops – fixed now (I hope).

  • frankv says:

    Hi Steve, I downloaded your code, but it refers to a file called USB.pm. Where can I get that from?

  • Steve says:

    Frank,

    It’s in the Perl Device::USB module – http://search.cpan.org/~gwadej/Device-USB-0.33/USB.pm

    Steve.

  • m_elias says:

    Hey guys, I'm having the same problem as frankv had but I don't know enough to know how to get it working and I can't find any tutorials this time. I have downloaded Device-USB-0.35.tar.gz and I have tried 'sudo cpan – Inline' and Make and Device::USB. I'm running Ubuntu server 10.10. I would appreciate any ideas or suggestions you might have.

  • Steve says:

    I don't use Ubuntu but for perl modules that aren't available in as repo as an rpm I generally do this:

     

    # perl -MCPAN -e shell

    cpan> install Device::USB

     

    Steve.

  • m_elias says:

    I managed to get it working by installing the libusb-dev and/or libusb-1.1-4 packages and then installing the cpan Device::USB module. Thanks for sharing your weather station program. I have adapted it for my needs and it's working nicely.

  • Steve says:

    Looks interesting – I don’t suppose you have an English translation of the page?

  • milasupport says:

    Hi SteveThis script is so good! Thank you for sharing it. However, I have some problems with the wind speed. If the weather station console shows about 3 m/s, the wslogger logs about 7 or 8 m/s with gusts of 15 to 17 m/s.Have you experienced anything like this? /Michael – DK 

  • Steve says:

    I do recall seeing something like this in the early days. Can you check the wind speed calculations in the script? They should be:

     

            $wind_speed = ($wind + (($wind_extra & 0x0F) <<8)) * 0.38;      # Was 0.1
            $gust_speed = ($gust + (($wind_extra & 0xF0) <<4)) * 0.38;      # Was 0.1
     

  • milasupport says:

    Hi Steve It is also written like that in my script. Perhaps it's because the console displays an Windspeed-average? /Michael Larsen 

  • Steve says:

    Michael, I believe there are a few variations of this weather station and based on your reported figures maybe the 0.1 figure commented out in my script might be needed for yours. I can't actually recall where I got this original figure from but maybe give it a try.

  • vasco says:

    Hi Steve, thank's for the script!It motivated me connect my wh1080 weather station to my raspberry pi and get the data from it using your script. Your script runs respectively it runs into an error: usb_claim_interface failedCouldn't connect to the Weather Station I started to figure out where the problem come from. When i hit lsusb i can see the weather station with its correct vendor and model id:pi@raspberrypi /usr/local/weather $ lsusbBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 05ac:1006 Apple, Inc. Hub in Aluminum KeyboardBus 001 Device 005: ID 1941:8021 Dream Link WH1080 Weather Station / USB Missile LauncherThen I thought about to print the content of the variables in the sub open_ws:printf "$dev\n";printf "$usb\n";printf "Device: %04X:%04X\n", $dev->idVendor(), $dev->idProduct();The result was:Device::USB::Device=HASH(0x1112d70)Device::USB=HASH(0x1205268)Device: 1941:8021 Unfortunately I dont have a clue where to heading to with the debugging. Maybe you have any suggestion to this issue? Thank's!cheersVasco

  • Steve says:

    Hi vasco, based on the error message I'm wondering if something else running has already claimed the interface?

  • vasco says:

    Hi Steve!Thank's for the advice! It's working now!cheers!Vasco

  • mwulz says:

    hello,thanks for your script. I got these Errors:Got a dud fixed block – reconnectingGot a dud fixed block – reconnectingGot a dud fixed block – reconnectingThen I decided to enable debug:a1 00 00 20 a1 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Got a dud fixed block – reconnectinga1 00 00 20 a1 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Got a dud fixed block – reconnecting79 25 0a 11 00 04 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Got a dud fixed block – reconnectingso the Weather Station don't send the 0x55 String on beginning of the data payload.It is a WH 1080 (froggit) ordered from Amazon.I tried to reset the Touchpanel – same result.

  • Steve says:

    I have just uploaded a new version (1.4) which adds writing a template file for uploading to the Weather Underground via the script at http://www.jerjanb.net/wu-upload/

  • pcAlko says:

    Hi Steve!Thank's for your great job. The script for the WH1080 runs great.But last week my Debian squeeze had an secure upgrade to perl i386 5.14.2-17.Now I get only :Retval: 8, Read -110 bytes00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Got a dud fixed block – reconnectingall the time.I checked the vendor and model from lsusb with your script -> it's be the sameMaybe you have any suggestion to this issue? Thank's ! cheers Alex

  • pcAlko says:

    UPPS! sorry my mistake! After rebooting of Weather-Station it run's again perfectly. SORRY. regards Alex (alias pcAlko)

  • jjap says:

    Hi, what a neat project!I tried your version 1.4 on my Raspberry Pi, after installing dependencies the device is detected but I too get the error message:   usb_claim_interface failed Couldn't connect to the Weather StationReboots were of no help. Reading the libusb  documentation about  the "claim_interface" method left me with the feeling of being a little over my head… Any hints would be greatly appreciated.   

  • Steve says:

    Hi jean, I haven’t used a Raspberry Pi but looking through the comments in looks like vasco does and had a similar problem but managed to resolve it so hopefully they may be able to assist.

  • jjap says:

    Thanks Steve, I should manage to find it. Again kudos for your project!

  • vasco says:

    hey guys

    i use Steve’s script (1.3) on a Raspberry Pi with raspbian. To get it work you need to install some perl packeges which you can find on cpan. I installed those:

    wget http://search.cpan.org/CPAN/authors/id/J/JT/JTBRAUN/Parse-RecDescent-1.967009.tar.gz
    wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/Bundle-CPAN-1.861.tar.gz
    wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/ExtUtils-MakeMaker-6.64.tar.gz
    wget http://search.cpan.org/CPAN/authors/id/S/SI/SISYPHUS/Inline-0.52.tar.gz
    wget http://search.cpan.org/CPAN/authors/id/G/GW/GWADEJ/Device-USB-0.35.tar.gz

    if you need any further information do not hesitate contact me…

    cheers vasco

  • GTRDRIVER says:

    @vasco:Im trying to  do the same on Raspberry PI – but i have problems to install the DEVICE-USB Module. I have installed libusb_dev  and and libusb on raspian – but i still geht build errors  that says that Perl is not able to find libusb.I hope you can help me !Best Regards – GTR

  • GTRDRIVER says:

    Back again – sorry for filling this #blog with "nonsense" – after setting " LIBUSB_LIBDIR=/usr/lib/arm-linux-gnueabihf/" everything works and i can  install the Module  Device::USB – Perhaps anyone can use this information. (All on Raspberry Pi)

  • GTRDRIVER says:

    Hello again – My Station now run with WH1080 and Raspberry PI – but sometimes i have this error-Message: 22:58:09  32  71  22.1   2.7  -2.0   2.7   0.0   2.7  SW  0.0  0.0  0.9 957.1Got a dud fixed block – reconnectingGot a dud fixed block – reconnectingGot a dud fixed block – reconnecting^CCan't call method "release_interface" on an undefined value at ./wslogger.pl line 142, <DATA> line 1.Anyone have a Idea whats going wrong here ? 

  • rmappleby says:

    I had a couple of minor issues with v1.4:Firstly, the timestamps put into the template file, for later use by http://www.jerjanb.net/wu-upload/, are derived from the systems localtime, but WeatherUnderground requires these times to be UTC. Additionally, although wslogger.pl calculates the dewpoint data, it doesn't write it to the template file for upload.Both of these can be resolved by changing the code that writes the template file to:        # Write template file for Weather Underground upload        if (length ($wu_upload_file) > 0) {                open (FH, ">$wu_upload_file")                        or die ("Unable to open $wu_upload_file : $!");                my $now_date = strftime "%m/%d/%y", gmtime;                my $now_time = strftime "%H:%M", gmtime;                print (FH "stationDate=$now_date\n");                print (FH "stationTime=$now_time\n");                print (FH "windDir=$wind_dirs_degs[$wind_dir]\n");                print (FH "wind10Avg=$wind_speed\n");                print (FH "windSpeed=$gust_speed\n");                print (FH "outsideHumidity=$outdoor_humidity\n");                print (FH "outsideTemp=$outdoor_temperature\n");                print (FH "dailyRain=$daily_rain_rate\n");                print (FH "barometer=$abs_pressure\n");                print (FH "outsideDewPt=$outdoor_dew_point\n");                print (FH "tempUnit=C\n");                print (FH "windUnit=km/h\n");                print (FH "barUnit=hPa\n");                print (FH "rainUnit=mm\n");                close (FH);        } Additionally I changed the dewpoint and windchill calculations to only return values to a single decimal place, though this isn't strictly necessary for the code to work:        my $outdoor_dew_point = sprintf "%.1f", dew_point($outdoor_temperature, $outdoor_humidity);        my $wind_chill_temp = sprintf "%.1f", wind_chill($outdoor_temperature, $wind_speed);Hope that's useful.

  • Steve says:

    Thanks for the feedback and contribution.

  • mwulz says:

    Hello,the same like GTRDRIVER says, always the "Got a dud fixed block" messages.Someone told me, the libusb has got a problem on raspberry PI – can anyone confirm this?Does anybody has a running setup on raspberry PI with a WS1080 ??

  • rmappleby says:

    Steve, would you have any objections to me forking your code? I notice you don't publish under any particular license, and would like to modify your code (quite significantly) to better meet my needs, and then make the result generally available to the community. Since I would probably host this on github, I would need to license the resulting forked code, which I would prefer to do under something very permissive, such as BSD-3. Thanks, Richard

  • Steve says:

    Go for it. I didn’t really think about licensing at the time so consider it in the public domain.

  • rmappleby says:

    Thanks Steve, that's much appreciated. I'll post a link to my code when I get it completed and up onto github.

5 Trackbacks

Leave a Reply