☔ DIY Zigbee rain gauge

In case anyone wants to try it, here is a more detailed post on using the counter integration instead of history stats. This won’t produce false readings when home assistant is restarted.

First set up a counter from the Helpers section in Settings → Devices & Services → Helpers. Make sure to tick the restore the last known value when HA starts.

Then add two automations, one to reset the counter each night, and the other to increment the counter each time the binary sensor goes from open to closed.

The rest of the config is the same except you reference the counter in the template sensor


  sensor:
      - name: Rainfall today
        unit_of_measurement: mm
        state_class: total_increasing
        unique_id: rainfall_today
        state: >-
          {% set count = states('counter.rain_tips') | int(0) %}
          {% set mm = count * 0.30303 %}
          {% if count >= 0 %}
            {{ mm|round(1, 'floor') }}
          {% endif %}
5 Likes

Hi,
I’m trying to create a rain gauge, but I’m using a cone to collect the rain. I’m wondering, should I use the surface area of the opening/diameter of the cone (not the small hole of course :wink: ), or should I use the entire surface area of the inside of the cone to calculate the rainfall?

You should use the surface area of the point where the drops enter the cone :slight_smile:

Thank you, so the area of the flat/horizontal surface/opening (I’m trying to get it clear, I’m not a native English speaker, sorry)? @parrel

Yes the horizontal surface
Ja, de horizontale oppervlakte :slight_smile:

Feel free to send a direct message for a dutch conversation

1 Like

yes, and within range of the zigbee signal. Pretty hard to be honest. Rain fall gets altered when the device is next to a wall, which doesn’t make it measure correctly. But i’m experimenting a bit.

Yes that’s also something to keep in mind

I mounted it on a “afdak” in my garden

I can also help you with the calculation. I made an excel for this, also to calibrate the rain gauge. That is also possible in Dutch :wink:

1 Like

Can you share your code for this? I am also Dutch, so I assume you used one of the Dutch weather forecast services (buienradar, buienalarm etc).

I will share the code later today, I’m not behind my laptop right now, but you can start by installing this

1 Like

Thanks (the mentioned integration was already installed, so that was an easy action :slight_smile: )

1 Like


This is the code for the top graph (You also need the Apexcharts integration)
It’s for the buienalarm entity, not buienradar.

    - type: custom:apexcharts-card
      graph_span: 24h
      now:
        show: true
      span:
        start: day
      all_series_config:
        stroke_width: 2
      series:
        - entity: sensor.rainfall_today
          name: Regenval
          color: '#039ae5'
          extend_to: now
        - entity: sensor.neerslag_buienalarm_regen_data
          name: Voorspelling
          extend_to: false
          color: grey
          unit: mm
          data_generator: >
            if (typeof entity.attributes.data.start == 'undefined') {return []}

            let start_date = entity.attributes.data.start * 1000;
            let start_state = Number(hass.states['sensor.rainfall_today'].state);

            return entity.attributes.data.precip.map((precip, index) => {
              if (index != 0) { start_date = start_date + (5 * 60 * 1000) }
              start_state += entity.attributes.data.precip[index] / 12;
              return [start_date, start_state];
            });
2 Likes

Thank you very much! Works perfectly!

1 Like

Why just not use internal HA Telegram integration? No need for NodeRed - makes notification service out of it and that’s it…

A good rain gauge has a measuring surface of at least 200 cm2, a “sharp” edge and a deep and steep funnel.
This minimizes the effect of drops on the edge and splashing on the measurement.
In theory, 1 “bucket” of water can evaporate between two rain showers. The water in the bucket does not evaporate very quickly, there is no wind and direct sunlight in the meter.
Raindrops that “stick” in the funnel do evaporate quickly. If the funnel is dirty, more water will stick and evaporate.

During my studies, a long time ago, I had to calibrate a rain gauge as a research assignment :wink:

I don’t know the tipping point (horizontal position) but if the right bucket is down. In my opinion a little bit more reliable, the “on” status takes longer which reduces the chance that “on” status is missed.

Does anyone have a piece of code to calculate the rain rate in mm per hour?

It’s in the original post!

My gosh, I’m feeling slightly stupid right now :relaxed:. Thanks @parrel

1 Like

I’ve added the trend binary sensor (which for some reason stays on when it starts to rain, but never goes to off, only at midnight). I’ve added the rain rate sensor, but that stays at the last calculated rate even though it stopped raining. What am I doing wrong? :frowning:

1 Like