Author Topic: Advice on Rain Gauge Hardware to work with WeeWX  (Read 588 times)

0 Members and 1 Guest are viewing this topic.

Offline martini

  • Member
  • *
  • Posts: 4
    • Doune-Knoydart
Advice on Rain Gauge Hardware to work with WeeWX
« on: January 25, 2021, 12:18:22 PM »
Hi,

Recently, I've started using a Weatherflow Tempest station in conjunction with WeeWX. The Tempest weather station works well but the haptic rain sensor is limited by generating flase readings when exposed to strong winds. Due to the integrated design of the Tempest station, it isn't possible to separate the rain sensor from the rest of the device. I've disabled the Tempest rainfall data into WeeWX and I wanted to get hold of a suitable rain sensor that I could use in conjunction with the Tempest while feeding the rainfall data into WeeWX.

I was wondering if anyone had any advice about a suitable rain gauge solution I could integrate with WeeWX? Likewise, I'm not sure if it possible to feed in data from a separate source into WeeWX at the same time as logging the Tempest data? I'd welcome hearing any views or advice that folk might have. Many thanks.

Online vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1158
  • K2BIG
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #1 on: January 25, 2021, 01:12:55 PM »
You can comment out the "rain=" line in your Tempest sensor_map to not save the haptic rain measurements.

WeeWX has the ability to read standalone sensors and incorporate their measurements into the WeeWX observation stream, using the data_services function.  Here's an external barometer example:

https://github.com/eyesnz/weewx_pi_sensors

My suggestion is to buy a *wired* Rainwise 111 tipping bucket kit, and throw away the indoor "pedometer" that comes with it to display 0.01" bucket tips.  Assuming that you are running WeeWX on a Raspberry Pi, it should be trivial to wire the bucket to the appropriate GPIO pins.  If nobody has an example data_services module shared, it should not be too complex to fork the above and add in GPIO counting logic and a software pushbutton debounce routine.....
WU Gold Stars for everyone! :lol:

Offline martini

  • Member
  • *
  • Posts: 4
    • Doune-Knoydart
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #2 on: January 26, 2021, 04:33:15 AM »
Many thanks for your helpful response. I'll see if I can give that a go. The problem I have is the length of wire I'd have to run from the rain sensor location to the RPi.

Online vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1158
  • K2BIG
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #3 on: January 26, 2021, 08:09:28 AM »
If your Pi is running on wifi, you can always move it to a more convenient location for the wire.  One of my weather Pi's is thumb tacked to our laundry room wall, in a VESA-mount case.  I knocked a 1" PVC conduit through the wall, so that I could get the Blitzortung cables into the house (also mounted on the same wall).

In the back of my mind, I sized the conduit large enough for a future tipping bucket wire and a coax cable for an outdoor antenna to make a second attempt at sending my station data via APRS radio.....
WU Gold Stars for everyone! :lol:

Offline LordRatner

  • Member
  • *
  • Posts: 6
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #4 on: October 19, 2021, 05:38:28 PM »
You can comment out the "rain=" line in your Tempest sensor_map to not save the haptic rain measurements.

WeeWX has the ability to read standalone sensors and incorporate their measurements into the WeeWX observation stream, using the data_services function.  Here's an external barometer example:

https://github.com/eyesnz/weewx_pi_sensors

My suggestion is to buy a *wired* Rainwise 111 tipping bucket kit, and throw away the indoor "pedometer" that comes with it to display 0.01" bucket tips.  Assuming that you are running WeeWX on a Raspberry Pi, it should be trivial to wire the bucket to the appropriate GPIO pins.  If nobody has an example data_services module shared, it should not be too complex to fork the above and add in GPIO counting logic and a software pushbutton debounce routine.....

Any chance you could go into a bit more detail here? I'm doing exactly as you say, hooking a Rainwise 111 bucket to my RPiZero W. I'm not sure how to modify that file to translate the bucket tips into the WeeWx rain data.

Thanks,
Seth

Online vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1158
  • K2BIG
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #5 on: October 19, 2021, 05:58:21 PM »
Commenting the rain= line in weewx.conf stops the WeatherFlow UDP driver from logging that particular sensor value.

You still need to write a Python data_services routine to count the tips via a GPIO pin and insert them into WeeWX.  The provided link is an example to base a custom rain tipper data_services from.....
WU Gold Stars for everyone! :lol:

Offline LordRatner

  • Member
  • *
  • Posts: 6
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #6 on: October 21, 2021, 03:25:05 PM »
Commenting the rain= line in weewx.conf stops the WeatherFlow UDP driver from logging that particular sensor value.

You still need to write a Python data_services routine to count the tips via a GPIO pin and insert them into WeeWX.  The provided link is an example to base a custom rain tipper data_services from.....
I got it working, except the "rain =" line i needed to comment out was in the driver file (in this case simulator.py), not weewx.conf.

My service is running by adding it in weewx.conf under [Engine]-->[Services]-->data_services.

But I don't know how to add variables into weewx.conf such as GPIO pin and bucket_size and have them pass into the service. How are variables in weewx.conf referenced?

For reference, here is the service to log the rain from the Rainwise 111:

Code: [Select]
import syslog
import weewx
from weewx.wxengine import StdService
from gpiozero import Button
import datetime
import time

DRIVER_NAME = "RW111GPIO"
DRIVER_VERSION = "0.1"

class Rw111GpioService(StdService):
    def __init__(self, engine, config_dict):
        super(Rw111GpioService, self).__init__(engine, config_dict)     
        d = config_dict.get('Rw111GpioService', {})
        self.rw111 = Rw111(**d)
        self.bind(weewx.NEW_LOOP_PACKET, self.load_data)
           
    def load_data(self, event):
        try:
            self.get_rain(event)
        except Exception as e:
            syslog.syslog(syslog.LOG_ERR, "rw111gpio: cannot read value: %s" % e)

    # Get Rainfall data
    def get_rain(self, event):
        rainfall = round(self.rw111.get_rainfall(),2)
        syslog.syslog(syslog.LOG_DEBUG, "rw111gpio: found rain value of %s cm" % rainfall)
        event.packet['rain'] = float(rainfall)
   
   
class Rw111(object):
    """ Object that represents a RainWise Wired Rain Gauge. """

    def __init__(self, **d):
        """ Initialize Object. """
        # Read from config the bucket size
        self.bucket_size = 0.1  # in mm
        self.rain_count = 0
        # Read from config which pin to use on the RPI GPIO
        self.rain_sensor = Button(6)
        self.rain_sensor.when_pressed = self.bucket_tipped
       
    def bucket_tipped(self):
        self.rain_count = self.rain_count + 1
       
    def get_rainfall(self):
        """ Returns rainfall in cm. """
        rainfall = (self.rain_count * self.bucket_size) / 10.0
        self.reset_rainfall()
        return rainfall

    def reset_rainfall(self):
        self.rain_count = 0   

I'd like self.bucket_size and self.rain_sensor to reference variables in weewx.conf, but I have no clue how to do that. The service is called in the weewx.conf file at the end:
Code: [Select]
[Engine]
    # The following section specifies which services should be run and in what order.
    [[Services]]
        data_services = user.Rw111GpioTest.Rw111GpioService,
« Last Edit: October 21, 2021, 03:48:09 PM by LordRatner »

Offline LordRatner

  • Member
  • *
  • Posts: 6
Re: Advice on Rain Gauge Hardware to work with WeeWX
« Reply #7 on: October 24, 2021, 09:45:00 PM »
Got it working!

This allows you to add a wired rain gauge to WeeWx via the GPIO pins on a Raspberry Pi. Thanks for the help!

https://github.com/lordratner/weewx_gpio_raingauge

 

anything