How to measure Integration of rain pulse counter into daily value

I use normally off, and the pulse is on.

Hi, no problem, and welcome to Home Assistant!
I think I would first check under developer tools if the entity really exist. Perhaps a typo in the name?
Than check in configuration, integrations if your esp has connection with HA.
With ESPhome you can monitor your esp with “log” from command line or HA user interface if you use ESPHome addon.
Hope this helps! good luck!

ok, that explains it… so GND connected to the relay, with a possible pull-down on the pin instead of my pull-up.
Wiring is completely reversed compared with what I have.

In this case delayed_off simply makes sure there are no 2 pulses faster than 100ms (which seem OK at 1 pulse =0.36mm/m2. Faster than 1 pulse every 100ms means actually more than 3 liters of rain per second for each m2 and if I had that I would have bigger drowning problems than the functionality of this sensor).

Thank you for clarifying this for me.

1 Like

@gdschut Hi, may I know why you changed from pulse_sensor to binary_sensor?

I simply could not get it to work properly, so I changed the setup so all the calculations are done bij HA instead of on the ESP. There is now a global var on the ESP counting all the pulses for the day, and uploading the number into HA by using a service call every minute or so, so HA knows all the actual pulses of today and calculates the amount of rain. Now this makes it also not depending on a stable network.
The count of pulses is reset by midnight, to start on the new day with zero again.

1 Like

How did you create the HA sensor for Daily Rain, sorry I am a little noob :slight_smile:

Edit: now with the right code
Found out I had two sensors (daily_rain and rain) and I thought I was using the daily_rain but in fact it was the other. For strange reasons I only get this working in configuration.yaml instead of in sensors.yaml. Does anybody know how to move this to sensors.yaml???

In configuration.yaml:

template:
  - sensor:
      - name: rain
        state: '{{(states.input_number.rain_pulse_count.state | float * 0.367) | round(1) }}'
        unit_of_measurement: "mm"
        state_class: measurement

Now with the new statistics it is also nice to add this sensor with a statistics lovelace card :slight_smile:
You need the state_class: measurement to get it into the statistics.
Another strange thing: No icon is accepted for this type of sensor… (don’t know why)

As you can see the sensor I use is named “rain” only, as it increases over the day, and is in fact a daily rain sensor. I use the utility meter for monthly calculations.

Haha, thanks, very stupid but I didn’t immediately think of that place :slight_smile: and that while it is already completely full. But thanks a lot!! Gonna try it right away :slight_smile:

Hmmm
image

And the sensor is not in Statistics… do I do something wrong? :slight_smile:

English please!

Sorry, I posted the wrong information. Figured it out now, and updated my previous post: How to measure Integration of rain pulse counter into daily value - #39 by gdschut

I think there is a mistake in the calculations.
1mm of rainfall, in 4.9mm x 110mm area, is 539 mm3 = 0.539 ml (not 5.39 ml)

Or should be 49mm?

1 Like

You’re right! I will correct it to 49 mm.
Thanks!

To simplify the process and avoid zeros, we should use Pulse Meter and not Pulse Counter Sensor.

Send the pulses to HA, create a template sensor to multiply by “0.367” and then with Utility Meter choose the desired cycle to measure - quarter-hourly, hourly, daily, weekly, monthly…

Yes indeed, letting HA do the counting is the most easy solution. The problem for me is that my connection is not always stable, thats why I prefered counting on the ESP side.

With Pulse Counter I was always getting 6 pulses instead of 1, and if divided by 6, when multiply by, ex.10, the result for each pulse was something like, 9.9987 or 10.001, really strange values (although they have no effect on the final result).

i Am trying this, however I have come up with a multiplier of 10 which seems way to high compared to everyone else.

I also set the unit_of_measurement to ml rather then mm for testing,
Then poured 100ml of water in and it reported 100ml,

Then changed the unit of measurement back to mm.

Is this sufficient? My multiplier is 10.

I connected one wire to GND and another to GPIO12 (D6) ona esp32 but can’t get any results.
Could someone please post ere the complete ESPhome code?

Watch out! The given ESPHome code is for another board, which means you have to adjust the pinnumbers and pins used to get it working on an ESP32 (whichever version you have…)
If you have troubles finding a usable pin you might have a look on a site like https://www.techtonions.com/esp32-pinout-simplified-no-more-confusion-when-choosing-gpios/

I know that, but I would like to see the complete esphome code so I can adjust to esp32 v3.

Im using GPIO12 but it’s not working.

Could someone please post it here?