AussieSusan / HP1000

Weewx driver for the HP1000 (WS1001, XC0422) Weather Station using WiFi connection
7 stars 4 forks source link

HP1000 driver with WS-1001 clone - "HP1000: Timed out too many times" #11

Closed stalkerGH closed 1 year ago

stalkerGH commented 1 year ago

Hi AussieSusan, author of HP1000 driver.

Recently I bought WS-1001 clone - HP1001 made by Conrad (Germany). Two or three years ago I've installed Weewx for my DIY weather station so I'm familiar with this software. I'm also long time Linux user so I'm not afraid of CLI.

So. I have working Weewx installation. I see logs (debug = 1 in weewx.conf). I've downloaded and successfully installed HP1000 driver (https://github.com/AussieSusan/HP1000). Weewx is reconfigured to use HP1000 driver. I know IP of my weather station, it has static address, like many devices in my LAN. When I start Weewx, I see in log:

weewx[13810] INFO main: Initializing weewx version 4.10.2 weewx[13810] INFO main: Using Python 3.7.3 (default, Jun 29 2023, 18:03:57) [GCC 8.3.0] weewx[13810] INFO main: Located at /usr/bin/python3 weewx[13810] INFO main: Platform Linux-5.10.103-v7+-armv7l-with-debian-10.13 weewx[13810] INFO main: Locale is 'pl_PL.UTF-8' weewx[13810] INFO main: Using configuration file /etc/weewx/weewx.conf weewx[13810] INFO main: Debug is 1 weewx[13810] INFO main: PID file is /var/run/weewx.pid weewx[13814] DEBUG main: Initializing engine weewx[13814] INFO weewx.engine: Loading station type HP1000 (user.HP1000) weewx[13814] INFO root: HP1000: HP1000 Starting weewx[13814] INFO root: HP1000: Using "netifaces" to determine broadcast mask weewx[13814] INFO root: HP1000: Address Mask = 192.168.0.255 weewx[13814] INFO root: HP1000: Retry count = 5.000000 weewx[13814] INFO root: HP1000: Socket timeout = 5.000000 weewx[13814] INFO root: HP1000: Loop delay = 15.000000 weewx[13814] INFO root: HP1000: Retry Wait = 5.000000 weewx[13814] INFO root: HP1000: Max Retry = 3.000000

Screenshot_20230719_171654

But after some time a message appears:

weewx[13814] INFO root: HP1000: Timed out too many times

repeated dozens of times.

Screenshot_20230719_171632

I started Wireshark to sniff the network traffic on my laptop in the same LAN as Weewx and weather station and got this:

60 4.225791451 192.168.0.106 192.168.0.255 UDP 82 48576 → 6000 Len=40 282 24.194043968 192.168.0.106 192.168.0.255 UDP 82 50680 → 6000 Len=40 511 44.162213176 192.168.0.106 192.168.0.255 UDP 82 37338 → 6000 Len=40

First column is packet number. Second - time of sniffing. Third - IP of my Raspberry with Weewx (192.168.0.106). Fifth - 192.168.0.255 is broadcast address, equal to Address Mask in Weewx log. UDP is network protocol. Sixth - packet length in bytes. Seventh - five digits number is port number of Weewx sending the packet; 6000 is destination port of weather station. Len=40 is packet size in bytes (8+8+24, see below). Screenshot_20230719_171459

According to description in HP1000 driver:

Communication starts with a UDP IP broadcast on the local subnet to port 6000 to see if the weather station responds. The broadcast packet is structured as:

Offset Value Structure Comment 0x00 PC2000 8 byte string Identifies the calling station 0x08 SEARCH 8 byte string Command 0x10 nulls 24 null bytes I think there could be structure here but sending nulls works!

Inspecting the packets I see hex dump:

0000 ff ff ff ff ff ff b8 27 eb dd 86 34 08 00 45 00 .......'...4..E. 0010 00 44 28 e0 40 00 40 11 8f 0f c0 a8 00 6a c0 a8 .D(.@.@......j.. 0020 00 ff bd c0 17 70 00 30 1d 20 50 43 32 30 30 30 .....p.0. PC2000 0030 00 00 53 45 41 52 43 48 00 00 00 00 00 00 00 00 ..SEARCH........ 0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0050 00 00 ..

So it seems Weewx that "asking" for weather station - so far, so good.

And here comes the question: why the Weewx and weather station can't talk to each other. Or maybe - why weather station is not responding to Weewx invitation?

Maybe I can hardcode IP of weather station in driver's code?

PS. I've sent this message to weewx-user mailing list but I repeat it here.

stalkerGH commented 1 year ago

I tried many ways and finally got it. IP, port and protocol were correct. I suspected router settings as the most likely cause. I have also PiHole (https://pi-hole.net) in my LAN, serving as advanced adblocker, DHCP, DNS and VPN in one Raspberry Pi Zero W box so it was another big potential point of failure. After trying many settings I returned to the very beginning.

So I started to play with the console's online weather services settings. First, I wanted to establish connection to Weewx - entered IP, port (the same as in HP1000 part of weewx.conf of course) but no luck.

Then I decided to register my station on WU - because I did not consider this option before; I wanted Weewx be only place to gather data. Next I digged on the web and found "interceptor" for Weewx (https://github.com/matthewwall/weewx-interceptor). It took next two hours of frustration. Configuration seems simple at first glance. After some Wireshark sniffing and reading documentation for interceptor I've cheated the console by changing DNS record for WU - instead of letting rtupdate.wunderground.com go to WU, I set it to 192.168.0.106 - Weewx installation (thank you PiHole for easy way to do it!). And then... something was happening, logs were filling with reasonable messages. Weewx started getting data from my HP1001 station :)

As the experiment I changed driver from interceptor to HP1000 from Susan and it also works. It's great because configuration is much more friendly then with interceptor. But it's good to know for the future that I have alternatives.

Summary: I should start with registering to WU, I would save myself a headache and few hours of life. I would also achieve success earlier if port number in drivers' configuration will be default (TCP 80) from the very beginning. With port 8000 which I've set, Weewx and console couldn't talk with each other. It's strange but that's exactly how it is. Before that change I had working webserver instance on port 80 so there was conflict between WWW and Weewx. I disabled WWW server and then everything worked as expected.

(Extended version of this message I've to Weewx users group: https://groups.google.com/g/weewx-user/c/VXLY2yC3BJw/m/H7lkVSBoBgAJ)

stalkerGH commented 1 year ago

Problem is now solved so I close the issue.