Page 1 of 1

Wake up from sleep on ISR

Posted: Tue Sep 03, 2019 4:39 am
by gibson12345
Hey everyone,

I've been trying to interface with an accelerometer to use as a way to wakeup from sleep if the device is shaken and also put it to sleep on an inactivity timer. I've managed to get the device to go to sleep on the timer just fine and I thought I had correctly enabled gpio wakeup with the following

Code: Select all

	gpio_wakeup_enable(LIS3DH_INTR, IRQ_WAKEUP_LEVEL == 1 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
    	esp_sleep_enable_gpio_wakeup();
but I can't seem to get any wakeup from the GPIO.

I know for sure that I'm receiving interrupts because when it's not asleep I receive the interrupt just fine. Are there any obvious causes that I might be missing?

EDIT:

So after some testing if I shake the accelerometer while asleep when it eventually wakes up from sleep from a timer it fires the ISR and relevant task after

Re: Wake up from sleep on ISR

Posted: Tue Sep 03, 2019 9:20 am
by WiFive
Light sleep or deep sleep?

Re: Wake up from sleep on ISR

Posted: Tue Sep 03, 2019 11:08 pm
by gibson12345
Light sleep. Deep sleep required RTC Gpio correct?

Re: Wake up from sleep on ISR

Posted: Tue Sep 03, 2019 11:39 pm
by WiFive
Yes. Have you tried the console example or light sleep example? Also your code is

Code: Select all

if(IRQ_WAKEUP_LEVEL == 1)
   level = GPIO_INTR_LOW_LEVEL
Is that what you want?

Re: Wake up from sleep on ISR

Posted: Wed Sep 04, 2019 12:13 am
by gibson12345
Hey WiFive,

Correct the interrupt signal is configured to be low active so that's fine.
I have tried the example light sleep code and it works just fine, as I stated above I have to interrupt working fine when it's awake and it wakes up off an interrupt just fine from a button or such but not from my accelerometer.
Any thoughts on why this might be?

Re: Wake up from sleep on ISR

Posted: Wed Sep 04, 2019 4:19 am
by boarchuz
Are you sure it's not waking up? Is it possible that it's waking, but not executing the ISR? What is the duration of the interrupt signal?

Re: Wake up from sleep on ISR

Posted: Wed Sep 04, 2019 5:37 am
by gibson12345
I figured out the issue thanks everyone.

Cheers,
Gibson