ESP32 - combining timer AND GPIO wake up

obod0002
Posts: 4
Joined: Sat Apr 13, 2019 2:34 pm

ESP32 - combining timer AND GPIO wake up

Postby obod0002 » Mon Apr 15, 2019 7:56 pm

Dear ESP-lovers,

I'm currently running one of my ESP32's as replacement for a broken rain sensor.
It measures temperature, humidity and pressure every 30minutes, broadcast it through WiFi and goes to deep sleep inbetween.

The rain sensor is a see saw and is connected to one of the GPIO's so whenever an impulse is generated, the ESP32 stores it in RTC memory.
When it's time to broadcast temperature, ... it also hands over the number of impulses of the rain sensor.

I'm using this coding fragment:
esp_sleep_enable_ext0_wakeup(GPIO_NUM_13,1);
esp_sleep_enable_timer_wakeup(30MINUTES);
esp_deep_sleep_start();

Unfortunately - or logically - the 30MINUTES start anew after every impulse of the rain sensor.

Is there any chance to avoid this?
I'd like to have the 30minutes to be the stable timing.

I've got a picture in mind how I could solve it in software. But then I would need to activate the WiFi whenever there's a GPIO impulse to receive the current (NTP) time and compare it with the previously stored one.
Not my favorite as the device is running on a LiFePO4 and WiFi is a bit energy-hungry.

Thanks a lot for any help or thoughts
obod0002

ESP_igrr
Posts: 1439
Joined: Tue Dec 01, 2015 8:37 am

Re: ESP32 - combining timer AND GPIO wake up

Postby ESP_igrr » Tue Apr 16, 2019 12:05 am

If I understand your problem correctly, you wish to wake up only after certain number of pulses from the sensor, and not on each pulse?
If so, please check the "system/ulp" example in IDF. It demostrates how to do pulse counting using ULP coprocessor, and wake up after given number of pulses.

obod0002
Posts: 4
Joined: Sat Apr 13, 2019 2:34 pm

Re: ESP32 - combining timer AND GPIO wake up

Postby obod0002 » Fri Apr 19, 2019 3:13 pm

thanks a lot for your help. I checked the source code - unfortunately it's a 'little' to sophisticated for my knowledge at the moment. But I'll work on that ... I might come back with some detailled questions when I've understood the basics.

Return to “ESP32 IDF”

Who is online

Users browsing this forum: Google [Bot] and 12 guests