Measuring rain with Home Assistant

Print Friendly, PDF & Email

Post to continue completing our home automation system, Or it can be interesting if you intend to set up a weather station… Today it's time for a rain gauge, at the end of the document we will know how to measure the volume of rain and be able to visualize it in Home Assistant, or perform some automation…

In my particular case I must confess that I started with a device printed with parts from a 3D printer but it didn't work out 100% reliable… It was something homemade, So the best business option I found, Because sometimes manufacturers' devices are more reliable… I acquired in AliExpress A spare part for a weather station that serves safely, for €17.34 you don't waste any more time 😉

Now, We will need one of these wonderful boards with a microcontroller, an ESP32 or a ESP8266 can be equally good for us, in which we will install the ESPHome firmware and with a few lines of code we will have it. I promise one day to make a post on how to install ESPHome on one of these devices, But wow, Way above, we will have ESPHome installed on our Home Assistant, we will connect the board via USB to the Home Assistant and we will be able to create our new device.

After adding and configuring your device, with the following code it would be enough for us, We connect the rain meter, one cable to GND and the other to any GPIO on our board. We indicate the unit of measurement, the update interval and multiplier of each 'shovel'’ that makes the meter balance, The volume it contains in mm:

sensor:
  - Platform: pulse_counter pin:
      number: GPIO12 inverted: True mode: INPUT_PULLUP unit_of_measurement: 'mm'
    name: 'esp32-portero-precipitacion-lluvia'
    update_interval: 1s filters:
      - multiply: 0.367

We engrave and install it on the board,

And we can add a card with the entity that created us! With this we will be able to visualize and measure the amount of rain.

If we also want to, Know how much it rains per hour, per day, per week, per month, or annually and then visualize it more elegantly, we must add the following integrations in the Home Assistant configuration file, they will be 'utility meters', We indicate their name and their reset cycle:

...
utility_meter:
  precipitacion_lluvia_horario:
    Name: "Precipitation Rain - Timetable"
    Source: sensor.esp32_portero_precipitacion_lluvia cycle: hourly precipitacion_lluvia_diario:
    Name: "Precipitation Rain - Daily"
    Source: sensor.esp32_portero_precipitacion_lluvia cycle: Daily precipitacion_lluvia_mensual:
    Name: "Precipitation Rain - Monthly"
    Source: sensor.esp32_portero_precipitacion_lluvia cycle: monthly precipitacion_lluvia_anual:
    Name: "Precipitation Rain - Annual"
    Source: sensor.esp32_portero_precipitacion_lluvia cycle: yearly
...

Now we can make a card to see what rained the last few weeks 24 hours:

type: Custom:Apexcharts-Card Header:
  show: true title: Rain - Last 24h show_states: True Series:
  - entity: sensor.precipitacion_lluvia_horario name: Cubic millimeters type: Area Opacity: 0.7
    colour: Blue group_by:
      Duration: 15It works for me: Avg graph_span: 24h update_interval: 5min

Example of rain in the last month:

type: Custom:Apexcharts-Card Header:
  show: true title: Rain - Last month show_states: false series:
  - entity: sensor.precipitacion_lluvia_diario name: Cubic millimeters type: column opacity: 0.7
    colour: Blue group_by:
      Duration: 1d func: Max graph_span: 30d update_interval: 5min

Or even the last year:

type: Custom:Apexcharts-Card Header:
  show: true title: Rain - Final year show_states: false series:
  - entity: sensor.precipitacion_lluvia_mensual name: Cubic millimeters type: column opacity: 0.7
    colour: Blue group_by:
      Duration: 30d func: Max graph_span: 365d update_interval: 5min

If you notice I use some call cards ‘ApexCharts‘ To draw graphs it is one of the best since you can mix metrics, Views, units…

I hope you found the post interesting! And as always, Thank you for moving this type of content on social networks!

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!

Using NFC tags in Home Assistant

16 of March of 2023

Monitoring Dell EMC Data Domain

23 of March of 2023