Author Topic: EasyWeatherIP and WS1001 Protocol  (Read 3670 times)

0 Members and 1 Guest are viewing this topic.

Offline Aussie Susan

  • Member
  • *
  • Posts: 38
EasyWeatherIP and WS1001 Protocol
« on: October 02, 2016, 10:33:37 PM »
I just fired up the EasyWeatherIP program on my iMac to was amazed that it found and connected to my WS1001 (clone running 2.3.3 firmware).
I particularly like that it can do this while the WS1001 is still connected directly to WU and reporting there.
I would live to do this with a program on one of my Raspberry PIs (2 or 3).
I can see the packets going back and forth between the iMac and the WS1001 but I really don't want to start reverse engineering the communications involved.
Is EasyWestherIP open source (I've looked but couldn't find anything through Google)?
Is the protocol used by EasyWeatherIP documented anywhere (i.e. the ports it can access, the command formats and responses etc.)?
Alternatively is there an equivalent program that runs on a Raspberry Pi (i.e. Linux)?
Thanks
Susan

Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #1 on: December 16, 2016, 04:39:47 PM »
I wrote a Perl program that gets the real-time weather data from the Ambient WS1001 console and writes an
output file that can be read by the Cumulus weather station program. The program establishes a TCP connection with the console and reliably gets the real-time data.

See:

https://github.com/wrbelfield/ws1001wxdata

Bill

Offline Dr__Bob

  • Member
  • *
  • Posts: 23
Re: EasyWeatherIP and WS1001 Protocol
« Reply #2 on: December 19, 2016, 09:56:43 PM »
Hi Bill,

thanks!  Your program works great.  Well, it does after I added "Broadcast => 1" to the UDP socket creation, as otherwise I couldn't broadcast on it.  That might be a difference between Windows and Unix.

How did you go about decoding the data?

Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #3 on: December 20, 2016, 04:50:11 PM »
Hi,

It's good to hear that it's working for you. I haven't yet tried running it on my Linux system. Initially I looked at an approach based on redirecting the console WU data to my local server. But this didn't work. So I contacted Ambient customer support and they sent me some limited documentation, which was enough to help me get started. The console messages are in the form of C++ structures. After some experimenting, I learned how to unpack them in Perl. The program was running for over a week without any lost data, until an MS update required a PC restart.

Bill

Offline brushwood69

  • Member
  • *
  • Posts: 10
Re: EasyWeatherIP and WS1001 Protocol
« Reply #4 on: December 23, 2016, 01:41:27 PM »
Hey Bill,

used your script and need a little help I think?? I get the wind data and pressure all great but the temp is all over the place?? My actual temp is 11.2 cent positive and indoor 20.8 cent positive humidity all correct. The data below is a copy of the script output??

TIA

x x x 2016-12-23 18:35:20 x 58 -6.22222264607747 98 -11.5555556615194 -11.7222224341498 -11.5555556615194 x 34331.2214066223 0.491744010658264 x 1.1176 x x SE x x x 0 x x x 0 0 0 x x x x x x



Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #5 on: December 23, 2016, 04:45:32 PM »
Hi,
The program assumes that the WS1001 console is sending weather data values based on US units (not metric). Since the weather data contained in the easyweather output file must be expressed in metric units, the program converts the appropriate data values before writing the easyweather output file. So if your ws1001 weather station is set to display metric units, the program should not perform the conversion. I can add an option to ws1001wxdata.pl to handle data given in metric units, so that the program does not convert the data values before writing the easyweather file. In the mean time, you could modify your copy of ws1001wxdata.pl so that it does not convert the affected data values. For example, replace

# outdoor temp
    $ewdata[9] = (($msgcontent[13] =~ /\d/) ? (($msgcontent[13] - 32.) * $f2c) : $msgcontent[13]);

with

# outdoor temp
    $ewdata[9] = $msgcontent[13];

-Bill



Offline brushwood69

  • Member
  • *
  • Posts: 10
Re: EasyWeatherIP and WS1001 Protocol
« Reply #6 on: December 23, 2016, 06:42:13 PM »
Hey Bill,

That's the ticket and now all working brilliant thanks.

BW69



Offline brushwood69

  • Member
  • *
  • Posts: 10
Re: EasyWeatherIP and WS1001 Protocol
« Reply #7 on: December 24, 2016, 08:58:28 AM »
Sorry another quick question!

For easyweatherplus.dat only:
28 - light reading (in Lux)
29 - UV index

Does CumulusMX support these do you know? I'm getting 0 in the gauges but not sure if the 28 & 29 fields are supported.

Cheers

BW



Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #8 on: December 27, 2016, 09:53:33 AM »
I'm currently running Cumulus release v1.9.4 (build 1099) on my PC, and the light reading
and UV index are displayed correctly. I haven't tried using CumulusMX. Make sure 'Extra Sensors'
is selected in the Station Settings screen.

-Bill

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #9 on: January 03, 2017, 10:51:21 PM »
I take my hat off to you  wx5020 for getting this working
I got your perl script working with my Wifi station on windows
kudos

I am now trying to convert your code to C# or similar to then be able to run it as a standalone .exe instead of having to use a perl interpretor
have you thought about doing that?
also any chance you can share with me the data protocol information you provided with?
thanks!

Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #10 on: January 06, 2017, 11:08:42 AM »
I'm happy to hear it's working for you. Initially I thought of writing the program in C, but soon realized it would be easier for me to get something running in Perl. It would be very useful to have a C implementation. I probably won't have a chance to work on a C version for awhile. Let me know if you do write a version of the program in C. Thanks.

I obtained some limited documentation from the Ambient support contact:
support@ambientweather.com

-Bill



Offline Dr__Bob

  • Member
  • *
  • Posts: 23
Re: EasyWeatherIP and WS1001 Protocol
« Reply #11 on: January 06, 2017, 11:17:28 AM »
And for others interested in this, I took your code and modified it a bit to make an output that the fileparse driver of weewx could use.  And I think that I've convinced mwall to try to include a python version in his interceptor package, so that there would be a native python implementation for weewx.

One thing that I have noticed, at least with my console:  the recv that gets the response of the NOWREPORT request sometimes hangs "forever".  It looks like sometimes the console doesn't respond, and then the recv blocks.  Some kind of a timeout probably has to be implemented around the recv.  That starts pushing my socket programming skills!


Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #12 on: January 06, 2017, 11:33:16 AM »
Are you using the latest version of ws1001wxdata.pl? A couple of weeks ago I modified the program so that it checks whether the console is connected before attempting to receive a message from the console. If necessary, it will reset the TCP connection.

-Bill

Offline Dr__Bob

  • Member
  • *
  • Posts: 23
Re: EasyWeatherIP and WS1001 Protocol
« Reply #13 on: January 06, 2017, 11:50:16 AM »
I just took a look at your latest version.  I don't think that anything will change.  My problem is in the "while(1)" loop.  Things will run perfectly fine for a few days and then the program will just hang. The only place that I can see that it will hang is on the recv (at line 170 of the current version).  Occasionally I'll also get a bad response, but that is handled by your error handling after the recv returns.  (Typically it's a message of length 3 that triggers that error code.)

Offline wx5020

  • Member
  • *
  • Posts: 12
Re: EasyWeatherIP and WS1001 Protocol
« Reply #14 on: January 06, 2017, 01:25:55 PM »
Take a look at the latest version. Near the beginning of the while(1) loop I added a test,

if(defined $client_socket->peerhost()) {

If the client (console) is no longer connected, the program resets the TCP connection. I think this will fix the problem.

-Bill

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #15 on: January 06, 2017, 11:52:05 PM »
I have managed to get this working to a degree (i.e can get raw data, for now ) in a compiled language (to a .exe ) :)

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #16 on: January 08, 2017, 12:47:15 AM »
struggling with the unpack perl command
how to deal with that in other compiler languages...

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #17 on: January 08, 2017, 05:00:58 AM »
OK, making progress , got the unpack working 90% now

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #18 on: January 08, 2017, 01:36:57 PM »
question:
the data I get here is in metric
but I see your perl code you convert it to metric as if its arriving as US units?
is that dependent on what units the easy weather software is set to?

Offline Dr__Bob

  • Member
  • *
  • Posts: 23
Re: EasyWeatherIP and WS1001 Protocol
« Reply #19 on: January 08, 2017, 01:43:44 PM »
Yup.  It looks like the EasyWeatherIP protocol sends the data in whatever units you've set up on the console, either through the console directly or through the EasyWeatherIP program (that you can get on the AmbientWeather website).

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #20 on: January 08, 2017, 01:47:18 PM »
I will have to check for that then (e.g check the barometer value) ;)

Offline ronhanson01

  • Member
  • *
  • Posts: 2
Re: EasyWeatherIP and WS1001 Protocol
« Reply #21 on: January 16, 2017, 06:21:27 PM »
OK, making progress , got the unpack working 90% now

Very interested if you got this working. Quite disappointed when I upgraded to the 1001 not realizing I couldn't use cumulus.

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 382
Re: EasyWeatherIP and WS1001 Protocol
« Reply #22 on: January 16, 2017, 07:59:13 PM »
Yes,I got it working great :)

Offline kalel410

  • Member
  • *
  • Posts: 9
  • Ambient WS-1001 Wifi Owner
Re: EasyWeatherIP and WS1001 Protocol
« Reply #23 on: February 26, 2017, 10:31:03 AM »
Having problems connecting to the WS-1001 Wifi.  I'm running Fedora 23.  The run_ws1001wxdata.sh's log file reports my local host address correctly and reports a broadcast address of 192.168.1.255:6000  however, the log keeps repeating "Sent UDP broadcast message of length 40"  "Server Waiting for WS1001 console connection on port 6500"  "client connection timeout" until it eventually times out completely and the script ends with "Timed out waiting for client (console) connection Interrupted system call".   Note that the perl script does include:  Broadcast => 1    Any ideas what could be happening or what more I need to do to get the script connecting to the ws1001 console?  Thanks!  --Kal

Offline kalel410

  • Member
  • *
  • Posts: 9
  • Ambient WS-1001 Wifi Owner
Re: EasyWeatherIP and WS1001 Protocol
« Reply #24 on: February 26, 2017, 11:13:57 AM »
I should also note that I know the IP and mac address of the WS-1001 Wifi console, and the console is pingable from my Fedora system, if that helps.  The WS console is on the same network as my Fedora system and the router does not have firewall restrictions between the two, because they're both internal (to my network) devices.   The WS is up and running and communicating with Weather Underground and can be seen locally by my EasyWeatherIP program under Windows 7.   --Kal

Having problems connecting to the WS-1001 Wifi.  I'm running Fedora 23.  The run_ws1001wxdata.sh's log file reports my local host address correctly and reports a broadcast address of 192.168.1.255:6000  however, the log keeps repeating "Sent UDP broadcast message of length 40"  "Server Waiting for WS1001 console connection on port 6500"  "client connection timeout" until it eventually times out completely and the script ends with "Timed out waiting for client (console) connection Interrupted system call".   Note that the perl script does include:  Broadcast => 1    Any ideas what could be happening or what more I need to do to get the script connecting to the ws1001 console?  Thanks!  --Kal