sleep() [ Sleep ]
Sleep and GPIO outputs
In most sleep modes, GPIO outputs retain their HIGH or LOW GPIO output states. The exception is HIBERNATE on Gen 2 devices, where outputs go into a high-impedance state during sleep.
This can result in unexpected current usage, depending on your design. You should pinMode(INPUT)
to disconnect the GPIO if you do not want the OUTPUT driven during sleep mode to get the lower. While this is not necessary if you are using Gen 2 HIBERNATE mode, it does not hurt to do so, allowing the same code to be used for both Gen 2 and Gen 3.
Make sure the external device can handle the pin being disconnected. This may require an external pull-up or pull-down, or you can just drive the pin always at the expense of slightly increased power usage.
Sleep mode | Gen 2 | Gen 3 | P2/Photon 2 |
---|---|---|---|
STOP | Preserved | Preserved | Preserved |
ULTRA_LOW_POWER | Preserved | Preserved | Preserved |
HIBERNATE | High-Z | Preserved | Preserved |