☔ DIY Zigbee rain gauge

Tags: #<Tag:0x00007fc40ff525c8> #<Tag:0x00007fc40ff52140>

Today I want to share with you how I made a wireless battery powered Zigbee rain gauge for $20. It measures the rainfall amount in mm or inches.

What you need:

This is the rain gauge from the outside. Now lets take it apart by taking the top case off.

The gauge works with a reed switch, that closes and opens again when the bucket tips. You can pull out the board and see the sensor.

To make it wireless, we have to cut the wire! I cut it about this length. Then carefully strip the wires till you see some copper.

The next step is to solder the wires to the Aqara door sensor.
Normally there is a reed sensor there but I desoldered it for another project. I would suggest you desolder it, so it can not interfere with the magnet of the rain gauge.

If that’s done, it looks like this. You can now test it. If you didn’t yet, pair the sensor to ZHA, Z2M, Deconz etc.

Then you just insert the Aqara sensor in the casing. Notice the wire goes over the casing. I couldn’t get it in there, so I marked the spot where the wire goes over the frame, and made a cutout. This way I can still get the top back on.

Testing:
ezgif.com-video-to-gif

So how do we calculate the rainfall? I found a useful amazon review from ‘packetrat’ for this rain gauge here. He explains how to calibrate the sensor.

You do need to calibrate it by measuring the surface collection area, and putting in a controlled amount of water from a syringe, etc. while counting the pulses. I measured mine at 5cm x 11cm, and 6 pulses per 10mL => 10/6 = 1.67mL per pulse.

1mm rain = 0.1511cm = 5.5 mL
1" rain = 2.54511cm = 139.70 mL

@ 6 pulses per 10mL => 10/6 = 1.67mL per pulse

pulses / mm = 5.5 / (10/6) = 3.3
pulses / in = 139.7/(10/6) = 83.82

mm / pulse = 0.30303
in / pulse = 0.01193

I also got 6 tips per 10ml so I used 0.30303mm per tip. If you use inches, it’s 0.01193 inch per tip. We can use that in a sensor to calculate the rainfall today, or in a week, or month, etcetera.

I set up two sensors to calculate this. One to count the times the state of the rain gauge was ‘closed’ today:

sensor:
  - platform: history_stats
    name: Raingauge tips
    entity_id: binary_sensor.raingauge_on_off
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

And one that calculates the amount of rainfall

sensor:
  - platform: template
    sensors:
      rainfall_today:
        friendly_name: Rainfall today
        unit_of_measurement: mm
        value_template: >-
          {% set count = states('sensor.raingauge_tips') | int %}
          {% set mm_per_pulse = 0.30303 %}
          {% set mm = count * mm_per_pulse %}
          {{ mm|round(1, 'floor') }}

That’s it! Time to test it out under the tap and see the rainfall sensor increase!

ezgif.com-video-to-gif-2

If you’re interested, I also made a wireless battery powered chair occupancy sensor this way.

If you got any questions, feel free to ask them!

40 Likes

Brilliant!

2 Likes

Just mounted the rain gauge in the garden! Now we just have to wait for the rain :stuck_out_tongue:.

3 Likes

For the calibration to be accurate don’t you need to take into account the surface area of the collection pan on top?

Or is that included somewhere and I missed it?

@finity

To be honest I don’t exactly know how the calculations work, but what I do understand is that 5x11=55 and that then relates to the 5.5 in the calculations.

Ah, OK. I did miss it then.

I didn’t realize the 5.5ml was based on that number.

That’s really cool.

Just ordered the rain gauge. Now the waiting start… I just hope that I remember what I wanted to do with it when I receive the package :crazy_face: #chinesewebshopissues

2 Likes

Lol, relatable. It took about 14 days for me to arrive with aliexpress standard shipping to The Netherlands.

10 out 10 bro like your thinking

2 Likes

I would expect most simple rain sensors to do one tip per “point” (0.01" or 0.254mm) of rain. New ones might natively count in metric e.g. 0.25mm, but I can’t see anyone designing/selling a rain sensor that needs harder maths than that.

I’m not trying to be critical of the methods used, but …

If you are only measuring to one significant digit (5, 11, 6) then the answer can’t have more than one significant digit in it, therefore: mm/pulse = 0.3 , in/pulse = 0.01

You could measure the rain collection area more exactly and allow for the rounded corners, and e.g. measure how much syringe water is needed for 100 tips.

1 Like

Thanks a lot for your reply. I will dive into this and make it more accurate

This is great. I ordered the same one and connected it to my KNX Bus. Just need to install it on the roof :slight_smile:

Amazing! Will Do that :grin: thanks for that diy

1 Like

Cool! I had to google what KNX was but that’s pretty cool! So this KNX is wired through your house and that way you can connect smart devices to it?

1 Like

Yes. It’s a “Cable Bus” System. Very reliable. As we build a new house this was the only option for me :slight_smile:
You need specific KNX components but it’s an open industry standard.
You get everything from Switches to Smokedetectors. It’s not cheap but as said it’s reliable, exist since over 30 years, has a wide support from all major electrical manufacturers in Europe/Germany and there are a few fancy things available which only exists in the KNX World like this sweet thing which I have in every room :slight_smile:

1 Like

I run the same thing on a knx binary interface. It works nicely since this spring, but it’s accuracy is not so great - always ~ 10% off of a classical measuring cup.
Doesn’t rain that often here so not much chances to calibrate. Did change mm/pulse about 6 times. Landed at 0,275 now.

Thanks for your reply. I’m still waiting for rain, lol. I might print a larger funnel for it later, to increase the resolution. Like this

Had the first real test this night. I have to say, it’s quite accurate with Buienradar (Dutch weather station).

4 Likes

Had quite some rain today, it was really put to the test! Still works great.

1 Like

This is just what I was looking for. I’ve had one of these kicking around in my garage unused for years, it had a standalone battery powered LCD display but had no idea how the gauge part worked and so no idea that it could be integrated in HA.

1 Like