Seth,
that's actually pretty easy to set up. My python script on the RPi runs in
an endless loop, waits for a bucket tip and only writes the cumulative
number of tips (ever) to a file and calculates the rain amount (total,
cumulative) by multiplying it with the bucket size. Before that, it reads
the current bucket count from that file. I don't have that on Github, it's
probably pretty ugly and simple, but works for me.
raincount = open("raincount.txt","rt")
count = int(raincount.read())
raincount.close()
On a bucket tip, or rather "button press", that "count" variable is
incremented by one and both count and rainfall mm written to the file:
count = count + 1
mm = count * bucketsize
f = open("raincount.txt", "w")
f.write(str(count))
f.close()
f = open("rainmm.txt", "w")
f.write(str(mm))
f.close()
As I have a bash script running every 5 minutes that takes care of the MQTT
of the rainfall and other sensor data from other sensors connected to the
Pi, along with writing the values to an influxdb, I just use that script to
read from rainmm.txt and publish that to MQTT.
To get the data into Weewx, I use this extension:
https://github.com/bellrichm/WeeWX-MQTTSubscribe
With that, you can have Weewx subscribe to any topic and push that data
into a Weewx variable. This is from weewx.conf:
[[topics]]
# Units for MQTT payloads without unit value.
# Valid values: US, METRIC, METRICWX
# Default is: US
unit_system = METRIC
[[[raspi1/rainmm]]]
# The WeeWX name.
# Default is the name from MQTT.
name = rain
# True if the incoming data should not be processed into WeeWX.
# Valid values: True, False
# Default is False
ignore = False
# True if the incoming data is cumulative.
# Valid values: True, False
# Default is False
contains_total = True
# The conversion type necessary for WeeWX compatibility
# Valid values: bool, float, int, none
# Default is float
conversion_type = float
# The units of the incoming data.
# Useful if this field's units differ from the topic's
unit_system's units.
# Valid values: see,
http://www.weewx.com/docs/customizing.htm#units
# Default is not set
units = mm
Hope that helps.
On Tuesday, December 27, 2022 at 5:03:45 PM UTC-6 Seth Ratner wrote:
> Could you share the programming for that? Maybe you have it on Github?
> Right now I have everything running on an RPi because the weather station
> is remote. But eventually I'd like to have Weewx running in a virtual
> machine, and the bucket will get connected to a RPi Pico and report the
> tips via MQTT as you have set up. I'd like to see what you're using to
> subscribe to the MQTT topic and feed it into the WeeWx loop.
>
> Thanks!
>
> On Tue, Dec 27, 2022 at 2:53 PM DrTron <[email protected]> wrote:
>
>> Good to know. The RPi where the bucket is connected to is actually not
>> the machine I run weewx on. I run MQTT to feed the (collective) rain amount
>> into weewx every time the bucket tips. My "main" weather station, if you
>> want to call it that, is a Ecowitt GW1100 with an outside temperature
>> sensor. At least that's what's configured as the weather station in weewx.
>> But yes, I wrote a simple systemd service script that restarts the python
>> script if necessary.
>>
>> On Tuesday, December 27, 2022 at 2:46:21 PM UTC-6 Seth Ratner wrote:
>>
>>> I've been happy with mine. Ecowitt sells a bird spike kit that fits it
>>> very well.
>>>
>>> The only downside is making the bucket play nice with whatever driver
>>> you're using for the main weather station. I created a service to
>>> accomplish this, which is linked in this thread. Come to think of it, I'll
>>> probably try to get Tom to take a quick look at the service, make sure I'm
>>> following the weewx best practices. He was incredibly helpful in getting my
>>> chill hours xtype to work.
>>>
>>> Make sure if you're using a service to count the bucket tips that you
>>> have a function to disconnect the pin from gpiozero. If something goes
>>> wrong and the weewx engine restarts, if your service hasn't released the
>>> pin when it exited then it will throw an error trying to reassign the pin.
>>> Took me a while to figure that one out..
>>>
>>> On Tue, Dec 27, 2022, 11:42 DrTron <[email protected]> wrote:
>>>
>>>> Thanks a lot, Seth!
>>>> I do it similarly in python: from gpiozero import Button
>>>> That button routine in the gpiozero library already has a debounce
>>>> function and I only count on "close" and just ignore the "open". So far it
>>>> works well, but my current gauge only has a 5 * 11 cm opening (=55cm2),
>>>> whereas the Rainwise probably has 5-6 times that.
>>>> Mine tips every 0.387mm of rain (calibrated to my best abilities), so I
>>>> guess I would benefit from the Rainwise gauge.
>>>>
>>>> On Tuesday, December 27, 2022 at 9:49:38 AM UTC-6 Seth Ratner wrote:
>>>>
>>>>> The Rain wise bucket is .01" / .254mm, and in testing it that has been
>>>>> accurate. It's more a matter of leveling the buckets once mounted, but
>>>>> it's
>>>>> not a difficult procedure.
>>>>>
>>>>> And yes, it just acts as a button/switch. I used the gpio library
>>>>> because it easily allows for treating the bucket like a button and
>>>>> assigning a function to it. You just want to make sure you only trigger
>>>>> the
>>>>> function when the reed switch closes, not on state change (which would
>>>>> give
>>>>> double the triggers per bucket tip, open and close). You can also change
>>>>> the settings to avoid bouncing.
>>>>>
>>>>>
>>>>> On Tue, Dec 27, 2022, 09:22 DrTron <[email protected]> wrote:
>>>>>
>>>>>> Seth,
>>>>>> Reviving this thread since I currently run a very similar setup.
>>>>>> However, I have a rather el-cheapo rain gauge and was looking into
>>>>>> replacing it with something more accurate, like the Rainwise RAINEW 111.
>>>>>>
>>>>>> Supposing you did calibrate the gauge, what bucket size did you
>>>>>> arrive at? Like, how many mm of rain per bucket tip?
>>>>>>
>>>>>> I already suspected that the wire from the gauge just contains the
>>>>>> button-like signal from the reed switch, as does my current gauge, so I
>>>>>> can
>>>>>> directly swap it out.
>>>>>>
>>>>>> Thanks!
>>>>>> On Monday, October 25, 2021 at 11:00:50 AM UTC-5 vince wrote:
>>>>>>
>>>>>>> Helps a lot, thanks. I kinda figured you had other power that
>>>>>>> you're just piggybacking the pi onto. Cool project.
>>>>>>>
>>>>>>> On Sunday, October 24, 2021 at 6:55:18 PM UTC-7 Seth Ratner wrote:
>>>>>>>
>>>>>>>> One wire to the chosen GPIO pin (set in weewx.conf) and one to GND.
>>>>>>>>
>>>>>>>> Nope. I might keep it for a future project, but not used here
>>>>>>>>
>>>>>>>> Yeah I'm guessing it's just because the wire is not direct burial
>>>>>>>> rated. I'll be routing mine through PVC
>>>>>>>>
>>>>>>>> I keep it in a shed in the orchard. All components are mounted to a
>>>>>>>> piece of plywood. For power I have a 20w solar panel with a Renogy
>>>>>>>> Wanderer
>>>>>>>> solar charge controller and a 6Ah battery. I may increase the battery
>>>>>>>> size,
>>>>>>>> as the system also powers an OpenSprinkler controller and 16 zone
>>>>>>>> extender.
>>>>>>>> The Pi serves as a WeeWx host, MQTT bridge with my HomeAssistant
>>>>>>>> server and
>>>>>>>> reverse proxy to serve the Open Sprinkler. I'll add an Ecowitt HS80
>>>>>>>> and
>>>>>>>> GW1100 soon to complete the station.
>>>>>>>>
>>>>>>>> I may once I finish things up, but there's not much to see with the
>>>>>>>> GPIO Rain Gauge since literally the only setup is connecting the two
>>>>>>>> wires
>>>>>>>> to the two RPi pins.
>>>>>>>>
>>>>>>>> On Friday, October 22, 2021 at 12:32:02 PM UTC-5 vince wrote:
>>>>>>>>
>>>>>>>>> Pretty cool. Dumb questions follow.....
>>>>>>>>>
>>>>>>>>> - how'd you wire it up ?
>>>>>>>>> - did you not use the little display that comes with the gauge
>>>>>>>>> ?
>>>>>>>>> - their manual says 'wire cannot be buried' - any idea why ?
>>>>>>>>> What if it was in a PVC conduit ?
>>>>>>>>> - what does your zeroW setup look like for powering it,
>>>>>>>>> keeping it dry, etc. ????
>>>>>>>>> - add photos and a nice writeup to your github page perhaps ?
>>>>>>>>>
>>>>>>>>> Reason I'm asking is that this seems like a pretty nice way for
>>>>>>>>> folks to add a rain gauge to stations like WeatherFlow that have
>>>>>>>>> notoriously inaccurate readings, assuming they are already running
>>>>>>>>> the nice
>>>>>>>>> WF UDP driver for that gear...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, October 22, 2021 at 7:22:05 AM UTC-7 Seth Ratner wrote:
>>>>>>>>>
>>>>>>>>>> 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
>>>>>>>>>>
>>>>>>>>>> On Friday, October 22, 2021 at 8:17:23 AM UTC-5 Seth Ratner wrote:
>>>>>>>>>>
>>>>>>>>>>> Fantastic, Thank you! That's exactly what I needed.
>>>>>>>>>>>
>>>>>>>>>>> On Thursday, October 21, 2021 at 2:39:32 PM UTC-5
>>>>>>>>>>> [email protected] wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Seth Ratner schrieb am Donnerstag, 21. Oktober 2021 um 21:27:14
>>>>>>>>>>>> UTC+2:
>>>>>>>>>>>>
>>>>>>>>>>>>> How are variables in weewx.conf referenced?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> By the variable config_dict you find in __init__. It is a
>>>>>>>>>>>> dictionary the represents weewx.conf. For Example the section
>>>>>>>>>>>> [Station] you
>>>>>>>>>>>> find as config_dict['Station']. The entry "location" in the
>>>>>>>>>>>> [Station]
>>>>>>>>>>>> section you find as config_dict['Station']['location'].
>>>>>>>>>>>>
>>>>>>>>>>>> If you need your own entries, define a section and put your
>>>>>>>>>>>> values there. Then you can access them via config_dict.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>> You received this message because you are subscribed to a topic in
>>>>>> the Google Groups "weewx-user" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/d/topic/weewx-user/K30GuHsZoE4/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>> [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/weewx-user/a063befb-f4df-4e15-acc7-37ed7af991c7n%40googlegroups.com
>>>>>>
>>>>>> <https://groups.google.com/d/msgid/weewx-user/a063befb-f4df-4e15-acc7-37ed7af991c7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "weewx-user" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/weewx-user/K30GuHsZoE4/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> [email protected].
>>>>
>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/weewx-user/4ee40432-20d1-43ab-9ad9-fc02aae4789en%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/weewx-user/4ee40432-20d1-43ab-9ad9-fc02aae4789en%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "weewx-user" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/weewx-user/K30GuHsZoE4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>>
> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/weewx-user/01fb0626-c59d-45fd-abd8-8e378508795dn%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/weewx-user/01fb0626-c59d-45fd-abd8-8e378508795dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/8573b2d6-514a-4f1b-820d-40d4131f1e53n%40googlegroups.com.