Wow to us interupt when ESP32 is in sleep

Hi

I have made a bee hive monitoring system that sleeps 1 h between each data collection

I need to tare or calibrate my weight sometimes and for that I have 2 buttons.

These 2 buttons are also sleeping, and don't work for me while in sleep.

const int switchTare         = 34;        
const int switchCalibrate    = 35;

How I do it today is first press reset, then system waits for 10 sec to sense if a button is pressed.

Q: How I like it to work is that I can press tare or calibrate without this reset/wait

Here is my if{} code today that starts after a reset:

if (reason == ESP_RST_POWERON) {
    if (digitalRead(switchCalibrate) == LOW) {           // check if switchCalibrate is pressed
      functionCalibrate();
    }
    if (digitalRead(switchTare == LOW) {                 // check if switchCalibrate is pressed
      functionTare();
    }

Here is my sleep command

esp_deep_sleep_start();   /wait for 1 h until new start

Can you give me some feedback how to make my calibrate and tare kick in, maybe some interupt?

M

Wake up the controller every few seconds and have it read your button pins. This way, you'll have to hold the button for a bit until the controller happens to be awake and can do something.

Otherwise select a power mode that keeps the GPIO's active all the time, but these will not be as economic as deep sleep since the GPIO clock and several other clocks will have to keep running.

That is not an option, I need to save battery. ESP32 uses a lot of power

If you don't use WiFi/BLE, it's not so bad, per se.

How about the option of having it wake up every x seconds? It only takes a few milliseconds to check the buttons.

Maybe this helps: ESP32 Touch Wake Up from Deep Sleep | Random Nerd Tutorials

No option, no BLE, NO WIFI, I use LoRa.

I need a answer how to wake up if a button is pressed

Check that link I gave above. It doesn't use the buttons you already have, but it should be easy enough to break out two of the touch-enabled GPIOs to the outside world.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.