I have been running WVIEW on Raspberry Pi with an Ambient WS2080 weather station for about 3 months now. For the most part this solution has worked great.
The only problem is the Ambient WX station will eventually start sending bad data. I have seen many reports of this problem, and I have it as well. Wview will rarely run much more than a week without a problem, and once in a while the problem occurs within a few days.
The problem can be fixed by cycling power on the weather station. Well, now, isn’t that just convenient. After some messing around, I found that if I leave the batteries out of the weather station (powering it from USB) AND reboot the RPI, the WX station will loose power and reset.
My work around has been to reboot the RPI every night. That has worked fairly well but a few days ago it hung up again 17 hours after the last reboot.
I decided to write a script that would monitor the wview log and if it sees problems accessing the WX station THEN reboot. That should reduce the number of reboots and reduce the length of time an actual hang goes uncorrected.
I know this works for a Raspberry Pi – the reboot kills power to the USB ports long enough to force a reset on the weather station. If you want to use this script on some other linux system, you might want to check that reboot restarts the WX station before proceeding.
Either you need to have the ability to send mail from the RPI or you will need to comment out the mail command in the following script. If you want to send mail and don’t have mail installed, please see
You need to create the file monitorWH1080. I created this in root’s home dir:
sudo su cd ~ cat > monitorWH1080 now copy the following and paste into your terminal emulator: #!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin #To prevent multiple reboots for one issue and to allow user #to override this process, wait 15 minutes after system restarts printf "Waiting 15 minutes before monitoring...\n" sleep 15m printf "Monitoring begins.\n" while (true); do if (( $(tail /var/log/wview.log | grep "bad magic number" | wc -l) > 0 ));\ then printf "WH1080 WX Station Error Detected\n" printf "Use 'killall monitorWH1080' to abort system restart." | \ mail -s "WH1080 WX Station Error Detected" \ -r"fromAddr@gmail.com(root.<hostname>)" \ toAddr@gmail.com sleep 10m printf "************************************\n" >> /var/log/wview.log printf "monitorWH1080 detected Error. Rebooting System.\n" >> \ /var/log/wview.log printf "************************************\n" >> /var/log/wview.log printf "rebooting...\n" reboot fi sleep 1m done Type control-D to end input and save file.
Now edit the script and fix the email address which are bold in the example.
Make the script file executable:
chmod 770 monitorWH1080
At this point, it is probably best to test the script and make sure it works to your satisfaction before setting it to run at system start up.
In one console session, run the script:
In another console session, force error messages into the log file:
sudo su while (true); do echo "bad magic number" >> /var/log/wview.log sleep 15s done
You will see status messages from the script telling you it is waiting to start, it has found an error, etc. Once you see it properly handle the error and reboot, put it into crontab.
To edit crontab, type:
sudo crontab -e
You need to add the @reboot command like this:
# For more information see the manual pages of crontab(5) and cron(8) # @reboot /root/monitorWH1080 # m h dom mon dow command
Reboot your system, then do the following to verify monitorWH1080 is running:
ps -A | grep monitorWH1080
Besides emailing the error, I would like a text too. At least for the time being.
This is pretty easy to add, if you’ve not done it before. You just need to know the gateway for your SMS provider. If you are reading this, chances are good you do know it. If not, have a look here:
then in the script’s destination email address where you already have