stm32duino / STM32LowPower

Arduino Low Power library for STM32
183 stars 52 forks source link

ExternalWakeup - add deepSleep() example - leak of current #54

Closed slavendam closed 3 years ago

slavendam commented 3 years ago

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 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 :)

ABOSTM commented 3 years ago

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.