☔ DIY Zigbee rain gauge

Yes. I wonder how accurate that would be. It would be a good experiment to have them side by side and compare the values.

Edit: reading the post now, I do not see an example of the quantity of rain. Only the intensity

Used the wrong word, indeed intensity but this might give an idea about the quantity.

That is interesting. I just placed an order on Aliexpress before knowing of this rain 2in1 sensor.

Hello,
This zigbee sensor normally detects water leak. If raining, heavy or little rain, it should trigger info. On top of, being AAA-Battery powered and less expensive, it should keep charge on a longer period than button cell based units.
You could also locate the main unit inside the rain collector box and the water detector contact, thanks to its contact cable, inside the collector …

HTH

Th

https://fr.aliexpress.com/item/1005005220809595.html
2024-08-14

Thanks Parrel for this great idea and the perfect instructions.
I used a wired Shelly Plus 1 + Shelly Plus addon for this. I didn’t want to use a battery as it can get very cold here in winter. I have no experience with ESP and Shellys are very easy to integrate with Home Assistant.
To mount the rain gauge, I ordered a “Misol mounting arm” from AliExpress.
I let 1740 ml drip into the rain gauge over 4 hours and measured 1100 flips.
1740 ml / 1100 flips = 1.5818181818 ml/flip
I measured the area of the rain gauge as 5470 mm².
5.47 ml = 1 mm of precipitation
5.47 ml / 1.5818181818 flips = 0.28918065 ml/flip

Now it just has to rain.

1 Like

hello. I am starting to use influxdb v.2 and grafana and wanted to stat the today, weekly, yearly on the same table, but not having much luck. Anyone would like to share their code??? Thx.

Can anyone hint me what’s the issue here?

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


sensor:
- platform: template
  sensors:
   device_tracker_1:
    value_template: "{% if is_state('device_tracker.ip13_von_1', 'not_home') %}Unterwegs{% elif is_state('device_tracker.ip13_von_1', 'home') %}Zu Hause{% else %}{{ states('device_tracker.ip13_von_1') }}{% endif %}"


- platform: 1
  display_options:
      - exchangerate
      - trade_volume_1
      
template:
  - sensor:
      - name: Rainfall today
        unit_of_measurement: mm
        state_class: total_increasing
        unique_id: rainfall_today
        state: >-
          {% set count = states('sensor.rainsensor_flips') | int(0) %}
          {% set mm = count * 0.30303 %}
          {% if count >= 0 %}
            {{ mm|round(1, 'floor') }}
          {% endif %}
        # If you have issues with the history sensor doubling after restarting HA, add the line below (@BigG)
        availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"

Error-Message:

bad indentation of a mapping entry (29:9)

26 |
27 | sensor:
28 | - platform: history_stats
29 | name: Rainsensor flips
--------------^
30 | entity_id: binary_sensor.regenmesse …
31 | state: ‘off’

Everything should be at the same depth for the History Stats sensor:

sensor:
  - platform: history_stats
    name: Rainsensor flips 
    entity_id: binary_sensor.regenmesser_contact
    state: 'off'
    type: count
    start: '{{ today_at() }}'
    end: '{{ now() }}'  
2 Likes

Awesome, that helped!

I don’t think this would work. I have a few of these at home and they basically need to be in a noticeable pool of water before going off reliably. It’s more than what a drizzle would provide unless it’s pooling, at which point you’d be seeing it in a normal rain gauge.

There may be promise for a wide funnel that collects rain into a narrow tube that is then measured with an ultrasonic sensor.

Hi,
Many thanks for this Tip !
One question : it’s mm by what ? cm2, m2 ??

It doesn’t really matter. If it would rain 1mm, and you have a square centimeter surface, the rain would still be 1mm ‘high’. Same goes for a square meter.

However 1mm of rain on a square meter equals 1 liter of water.

1 Like

Hello,
I have a problem with this sensor:

- platform: history_stats
  name: Rainsensor flips
  unique_id: rainsensor_flips
  entity_id: binary_sensor.rainsensor_on_off #The aqara sensor
  state: "off"
  type: count
  start: "{{ today_at() }}"
  end: "{{ now() }}"

If the state is “off”, every day will calculate fake 1 flip or 0.3mm of rain
is there any solution to fix this?

Did you use the method in the original post? If yes, then the state should only be ‘off’ for a split second when the bucked flips. If it is off for a longer period of time, it might has missed a state update. Tip the bucket to fix it. Happened to me once.

yep, exact the same:

template:
  - sensor:
      - name: Rainfall today
        unit_of_measurement: mm
        state_class: total_increasing
        unique_id: rainfall_today
        state: >-
          {% set count = states('sensor.rainsensor_flips') | int(0) %}
          {% set mm = count * 0.30303 %}
          {% if count >= 0 %}
            {{ mm|round(1, 'floor') }}
          {% endif %}
        # If you have issues with the history sensor doubling after restarting HA, add the line below (@BigG)
        availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"

How do I modify the code to add a second rainfall sensor? I have one working well now - I had to modify the code by taking out the x2 multiplication I had added to get it to accurately count the rainfall and doubling the measured amount for each tip of the sensor to stop it adding a ghost tip when it resets at midnight.
I have been following this thread for some time and have (I think) read every entry, but I am not sure if I missed this although I am aware there were a couple of users with more than one sensor. Is it as simple as adding another entity to the configuration yaml?
Thanks!!!
P.S. The door sensor I used doesn’t have a reed switch so always only did a brief Close as the magnet passed (? Hall Sensor) which was why I had modified the code to double the quantity measured and appeared reasonably accurate with my local forecasts as multiplying the amount by 2 created the extra measurement at midnight although I’m not sure why this happened.

As your not using the standard configuration, I think it’s best to post your code before we can help you

Hi parrel hope this helps :slight_smile:

sensor:
  - platform: history_stats
    name: Rainsensor flips 
   ### REPLACE ENTITY_ID WITH YOUR SENSOR ID
    entity_id: binary_sensor.rainfall_amount_opening
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'
    
template:
  - sensor:
        - name: Rainfall today
          unit_of_measurement: mm
          state_class: total_increasing
          unique_id: rainfall_today
          state: >-
           {% set count = states('sensor.rainsensor_flips') | int(0) %}        
           {% set mm = count  * 0.66316 %}
           {% if count >= 0 %} 
             {{ mm|round(1, 'floor') }}
           {% endif %}
          # If you have issues with the history sensor doubling after restarting HA, add te line below (@BigG)
          availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"

Thank you :slight_smile:

sensor:
  - platform: history_stats
    name: Rainsensor flips 
   ### REPLACE ENTITY_ID WITH YOUR SENSOR ID
    entity_id: binary_sensor.rainfall_amount_opening
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

  - platform: history_stats
    name: Rainsensor flips 2
   ### REPLACE ENTITY_ID WITH YOUR SENSOR ID
    entity_id: binary_sensor.rainfall_amount_opening_2
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

    
template:
  - sensor:
        - name: Rainfall today
          unit_of_measurement: mm
          state_class: total_increasing
          unique_id: rainfall_today
          state: >-
           {% set count = states('sensor.rainsensor_flips') | int(0) %}        
           {% set mm = count  * 0.66316 %}
           {% if count >= 0 %} 
             {{ mm|round(1, 'floor') }}
           {% endif %}
          # If you have issues with the history sensor doubling after restarting HA, add te line below (@BigG)
          availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"

        - name: Rainfall today 2
          unit_of_measurement: mm
          state_class: total_increasing
          unique_id: rainfall_today
          state: >-
           {% set count = states('sensor.rainsensor_flips_2') | int(0) %}        
           {% set mm = count  * 0.66316 %}
           {% if count >= 0 %} 
             {{ mm|round(1, 'floor') }}
           {% endif %}
          # If you have issues with the history sensor doubling after restarting HA, add te line below (@BigG)
          availability: "{{ (states('sensor.rainsensor_flips_2') not in ('unknown', 'unavailable')) }}"

Hi parrel, thank you very much :grinning:

1 Like