Function attachInterruptWakeup is declared in STM32LowPower.h as:
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
which means that if you call LowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING); with deepSleep(), it will call LowPower_EnableWakeUpPin function for SHUTDOWN mode by default. Result of this is that pin is left floating during sleep and there is current leakage.
To be precise, without including LowPowerMode in call, I measured 70uA current during deepSleep, and with adding DEEP_SLEEP_MODE current is 1.6uA.
So solution is to call:
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING, DEEP_SLEEP_MODE);
Please add this to example (at least to comment) so someone else will spare couple of hours to investigate what is missing :)
Hi @slavendam,
Thanks for pointing out this issue.
I proposed a Pull Request to fix that: #55
I set SLEEP_MODE parameter to match with LowPower.sleep()
And I added a comment to highlight this match.
In ExternalWakeup example there is line 36 which is just for shutdown() mode https://github.com/stm32duino/STM32LowPower/blob/9e7829f3d7450f8b91e277474d1e8f48f8e67fe1/examples/ExternalWakeup/ExternalWakeup.ino#L36
Function attachInterruptWakeup is declared in STM32LowPower.h as:
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
which means that if you callLowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING);
with deepSleep(), it will call LowPower_EnableWakeUpPin function for SHUTDOWN mode by default. Result of this is that pin is left floating during sleep and there is current leakage.To be precise, without including LowPowerMode in call, I measured 70uA current during deepSleep, and with adding DEEP_SLEEP_MODE current is 1.6uA.
So solution is to call:
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING, DEEP_SLEEP_MODE);
Please add this to example (at least to comment) so someone else will spare couple of hours to investigate what is missing :)