Waking up from deep sleep with rain gauge

Hello guys,I’m building project of weather station solar powered with an esp32 on esphome.
But I have one issue at this time, maybe someone of you could help me, I searched a lot on google, but nothing worked…
So, I have a rain gauge sensor (https://cdn.sparkfun.com/assets/d/1/e/0/6/DS-15901-Weather_Meter.pdf) :

platform: pulse_counter
  pin:
    number: GPIO27
    inverted: True
    mode: INPUT_PULLUP
  unit_of_measurement: 'mm'
  update_interval: 2s
  name: 
  id: rain_meter

and a deep sleep component:

deep_sleep:
  id: deep_sleep_control
  sleep_duration: 120s
  run_duration:
    default: 10s

Then I want that when it’s raining, and when my rain meter measure 0,3mm (one gauge), it wake up my ESP32, for send this data to my home assistant
I tried the wakeup_pin_mode, the esp32_ext1_wakeup but nothing worked… maybe I did something wrong with mode of them…

Thanks for reading me.

you might want to look at

https://ncrmnt.org/2021/12/06/optimizing-esp8266-esphome-for-battery-power-and-making-an-ice-bath-thermometer-as-well/

It would help if you shared the yaml with wakeup_pin or similar configured - it’s a bit hard to tell were you may have gone wrong without the code.

I assume you only what to know “it’s raining”, not how much rain you are actually getting. Deep sleep sensors are not a good choice for monitoring continuous events like rainfall.

deep_sleep:
  id: deep_sleep_control
  sleep_duration: 120s
  run_duration:
    default: 10s
    gpio_wakeup_reason: 10s
  wakeup_pin: 
    number: GPIO27
    inverted: True
    mode: INPUT_PULLUP

  

 
sensor:
  - platform: pulse_counter
    pin:
      number: GPIO27
      inverted: True
      mode: INPUT_PULLUP    
    unit_of_measurement: 'mm'
    update_interval: 2s
    accuracy_decimals: 3
    name: 'station_meteo_compteur_pluviometre'
    id: rain_meter
    filters:
    - multiply:  0.01

10 seconds is a really short wakeup time - especially if using DHCP. Does your device fully come up and connect within that time?

You may want to try setting wakeup_pin_mode: to KEEP_AWAKE as well, otherwise it will go back to sleep after 10 seconds regardless.

I assume you are using deep sleep because you are running on batteries?

Hello buddy, Yes my device fully come up in 5sec, actually i’m on wifi, but after I want to made it in 4G/5G LTE.
Yep, I’m running on batterie with solar cell. I tried with KEEP_AWAKE too. and doesn’t work.
I want that when it’s raining, and my gauge mesuring his first bucket, thats wake up my esp32 to send data of this measurement to my home assistant

Ok - so what isn’t actually “working”? Is the device not waking? Or not counting? It won’t count the wake tip as part of the sensor and as defined above will only stay awake for 10 secs before shutting down again. So if you are getting light rain (less than one tip per second) then it won’t increment the sensor at all.

Yep sorry, When I said not working, is because the esp32 doesn’t waking up when the rain gauge is activated, when it measures its volume of rain to activate the pendulum

When I put off the deep sleep system, and activate the rain gauge, thats work, it measure well.

But I want the device to be in deep sleep when it’s raining hard enough to activate the pendulum, it must wake up the esp32 so that these measurements can be added to my home a

So are you sure the gauge goes low when tipping? The diagram on the data sheet implies it does, but have you tested it with a multimeter or scope?

I didnt tested it but I think it is, cause when I disable the deep sleep module, that works very well.
But I want it to work as wake up pin when its raining and my ESP32 is in deep_sleep

Ah yes - of course. Well you are using the correct pin, your yaml looks correct - so I am out of ideas. My only sensor that uses pin wakeup leaves out the inverted: true line. It works fine:

deep_sleep:
  run_duration: 60s
  sleep_duration: 6h
  wakeup_pin:
    number: GPIO04
    mode: INPUT_PULLUP
  wakeup_pin_mode: INVERT_WAKEUP
  id: deep_sleep_1

The wakeup_pin_mode: line is because it can get stuck in a closed state and so it will wake again on open.

I am also thinking to add a rain gauge in the back yard which will need to be battery powered.

In the case of a rain gauge, it is impossible to predict when the rain might start, or how heavy the rain will be - ie how long between the pulses generated as the bucket empties and the next bucket fills up.

I have been wondering if this is feasible … so thanks Daryl for confirming this works for you.

As you say, it wont count the bucket tip which does the waking up, or any before the ESP32 is fully up.
Which started me thinking that really I am after the number of tips per minute (or per hour for long-term statistics) rather that recording each individual bucket tip with millisecond timing.

I really am not into electronics, but am assuming there may be a simple electronic circuit which can count the number of pulses received, and which can be read and reset (say every minute) by the microcontroller.

I personally think that battery powered wifi sensors using deep sleep have limited use cases. They are good for event sensors (a mailbox sensor like my snippet above) or for sensors that don’t require continuous data (I have a lux sensor for outside light control that wakes every 10 minutes).

I use a lot of 433MHz sensors and my weather sensors are Ecowitt brand. The rain sensor has been running for over 2 years on a single AA battery. You do need one or more 433MHz base stations running on permanent power though.

BUT - this is just my opinion, other users may have differing experience.

Hey thanks guys for all your answers. But still not working, I tried with deleting “inverted mode : true”.
I don’t know if it’s really possible to wake up ESP32 by pulse counter…

Hello back there, keep trying to make it worth last week but still nothing…
Maybe I can’t made a wakeup by pin, when the default wake up is on too ?
Only one mode of wake up can be enabled?

update

deep_sleep:
id: deep_sleep_control
run_duration:
default: 30s
gpio_wakeup_reason: 30s
sleep_duration: 120s
wakeup_pin:
number: GPIO13
inverted: true
mode:
input: true
pullup: true

With this code, it’s waking up from deep_sleep when it’s raining, but I think that my esp is waking up to slow to add 0,3mm to my pulse_counter