sleep() [ Sleep ]

HIBERNATE (SystemSleepMode)

// EXAMPLE
SystemSleepConfiguration config;
config.mode(SystemSleepMode::HIBERNATE)
      .gpio(WKP, RISING);
System.sleep(config);

The SystemSleepMode::HIBERNATE mode is the similar to the classic SLEEP_MODE_DEEP. It is the lowest power mode, however there are limited ways you can wake:

Wake Mode Gen 2 Gen 3 Gen 4
GPIO WKP RISING Only WKP
Time (RTC) 1
Analog    

1Tracker SoM can wake from RTC in HIBERNATE mode. Other Gen 3 devices cannot.

Typical power consumption in hibernate sleep mode, based on the wakeup source:

Device GPIO RTC
P2 114 uA 115 uA
M404 44 uA 43 uA
M524 26 uA 27 uA
T523 Eval 103 uA 95 uA
T402 Eval 103 uA 95 uA
Boron 2G/3G 146 uA n/a
Boron LTE 106 uA n/a
B402 SoM 26 uA n/a
B523 SoM 30 uA n/a
Argon 65 uA n/a
Electron 114 uA 114 uA
Photon 114 uA 114 uA

In this mode on wake, device is reset, running setup() again.


Gen 3 Devices (nRF52) (B-Series SoM, Tracker SoM, Tracker One, Boron, Argon, and E404X):

  • On the Argon, Boron, B-Series SoM, and E404X you can only wake by pin, not by time, in HIBERNATE mode.

  • On the Tracker SoM, Tracker One, and Monitor One, you can wake by time from HIBERNATE mode using the hardware RTC (AM1805).

  • You can wake from HIBERNATE (SLEEP_MODE_DEEP) on any GPIO pin, on RISING, FALLING, or CHANGE, not just WKP/D8 with Device OS 2.0.0 and later on Gen 3 devices.

  • Since the difference in current consumption is so small between HIBERNATE and ULTRA_LOW_POWER, using ULTRA_LOW_POWER is a good alternative if you wish to wake based on time on Gen 3 devices. The difference is 106 uA vs. 127 uA on the Boron LTE, for example.

  • GPIO are kept on; OUTPUT pins retain their HIGH or LOW voltage level during sleep.

  • On Gen 3 devices the RTC does not run in HIBERNATE sleep and clock time and date will not be valid until the next cloud connection.

  • Gen 3 devices (Argon, Boron, B-Series SoM, E404X, Tracker SoM, Tracker One), can wake on analog voltage comparison.


P2 Devices (RTL872x):

  • The P2 does not support holding a GPIO in OUTPUT mode when in HIBERNATE mode. The pin will go into high impedance mode.

  • The P2 can only wake from HIBERNATE mode on the pins listed below with the note "Pin can wake from HIBERNATE sleep," RISING, FALLING, or CHANGE.

  • On the P2, when waking from HIBERNATE the RTC will be reset and clock time and date will not be valid until the next cloud connection.

  • The P2 does not support wake on analog, BLE, or UART serial.

These P2 pins can wake from HIBERNATE sleep mode:

Pin Pin Name Description Interface MCU
30 D10 / WKP D10 GPIO, Serial 3 CTS, WKP. (Was WKP/A7 on P1.) Pin can wake from HIBERNATE sleep PA[15]
40 S0 / D15 S0 GPIO, PWM, SPI MOSI, Serial3 TX, I2S MCLK. (Was P1S0 on P1.) Pin can wake from HIBERNATE sleep PA[12]
41 S1 / D16 S1 GPIO, PWM, SPI MISO, Serial3 RX. (Was P1S1 on P1.) Pin can wake from HIBERNATE sleep PA[13]
42 S2 / D17 S2 GPIO, SPI SCK, Serial3 RTS. (Was P1S2 on P1.) Pin can wake from HIBERNATE sleep PA[14]
45 D2 D2 GPIO, Serial2 RTS, SPI1 MOSI Pin can wake from HIBERNATE sleep PA[16]
51 D3 D3 GPIO, Serial2 CTS, SPI1 MISO Pin can wake from HIBERNATE sleep PA[17]
52 D4 D4 GPIO, Serial2 TX, SPI1 SCK Pin can wake from HIBERNATE sleep PA[18]
53 D5 D5 GPIO, Serial2 RX, SPI1 SS Pin can wake from HIBERNATE sleep PA[19]
  • On the P2, pins S4, S5, and S6 do not support pull-up or pull-down in HIBERNATE sleep mode. Use an external pull resistor if this is required. These also cannot be used as wake from hibernate sleep mode.
Pin Pin Name Description Interface MCU
33 S6 / D21 S6 GPIO, I2S WS. (Was P1S6/TESTMODE on P1.) No internal pull up or pull down in HIBERNATE sleep mode. PB[31]
47 S4 / D19 S4 GPIO, I2S RX. (Was P1S4 on P1.) No internal pull up or pull down in HIBERNATE sleep mode. PA[0]


Photon 2 Devices (RTL872x):

  • The Photon 2es do not support holding a GPIO in OUTPUT mode when in HIBERNATE mode. The pin will go into high impedance mode.

  • The Photon 2 can only wake from HIBERNATE on the pins listed below with the note "Pin can wake from HIBERNATE sleep," RISING, FALLING, or CHANGE.

  • On the Photon 2, pin D10 is in the same position as the Argon/Feather pin D8.

  • On the Photon 2, when waking from HIBERNATE the RTC will be reset and clock time and date will not be valid until the next cloud connection.

  • The Photon 2 does not support wake on analog, BLE, or UART serial.

Pin Name Description Interface MCU
D2 D2 GPIO, Serial2 RTS, SPI1 MOSI Pin can wake from HIBERNATE sleep PA[16]
D3 D3 GPIO, Serial2 CTS, SPI1 MISO Pin can wake from HIBERNATE sleep PA[17]
D4 D4 GPIO, Serial2 TX, SPI1 SCK Pin can wake from HIBERNATE sleep PA[18]
D5 D5 GPIO, Serial2 RX, SPI1 SS Pin can wake from HIBERNATE sleep PA[19]
D10 / WKP D10 GPIO. Serial3 CTS, WKP. Was D8/WKP on Gen 3. Pin can wake from HIBERNATE sleep PA[15]
MISO / D16 D16 GPIO, S1 GPIO, PWM, SPI MISO, Serial3 RX. Pin can wake from HIBERNATE sleep PA[13]
MOSI / D15 D15 GPIO, S0 GPIO, PWM, SPI MOSI, Serial3 TX Pin can wake from HIBERNATE sleep PA[12]
SCK / D17 SPI SCK, D13 GPIO, S3 GPIO, Serial3 RTS Pin can wake from HIBERNATE sleep PA[14]

On the Photon 2, pin S4 is in the position of A4 on the Argon and other Feather devices. It does not support pull-up or pull-down in HIBERNATE sleep mode. Use an external pull resistor if this is required. These pins also cannot be used to wake from hibernate sleep mode.

Pin Name Description Interface MCU
S4 / D19 S4 GPIO, Was A4 on Gen 3. No internal pull up or pull down in HIBERNATE sleep mode. PA[0]


M-SoM Devices (RTL872x):

  • The M-SoM does not support holding a GPIO in OUTPUT mode when in HIBERNATE mode. The pin will go into high impedance mode.

  • The M-SoM can only wake from HIBERNATE mode on the pins listed below with the note "Pin can wake from HIBERNATE sleep," RISING, FALLING, or CHANGE.

  • On the M-SoM, when waking from HIBERNATE the RTC will be reset and clock time and date will not be valid until the next cloud connection.

  • The M-SoM does not support wake on analog, BLE, or UART serial.

Pin Pin Name Description Interface MCU
36 TX / D9 Serial TX, PWM, GPIO, SPI1 MOSI, I2S MCLK Pin can wake from HIBERNATE sleep PA[12]
38 RX / D10 Serial RX, PWM, GPIO, SPI1 MISO Pin can wake from HIBERNATE sleep PA[13]
40 D3 D3 GPIO, Serial1 CTS flow control (optional), SPI1 SS Pin can wake from HIBERNATE sleep PA[15]
42 D2 D2 GPIO, Serial RTS flow control (optional), SPI1 SCK Pin can wake from HIBERNATE sleep PA[14]
47 A7 / WKP A7 Analog In, WKP, GPIO D28 Pin can wake from HIBERNATE sleep PA[20]
48 D8 D8 GPIO, SPI SS Pin can wake from HIBERNATE sleep PA[19]
50 MISO / D11 D11 GPIO, PWM, SPI MISO Pin can wake from HIBERNATE sleep PA[17]
52 MOSI / D12 D12 GPIO, PWM, SPI MOSI Pin can wake from HIBERNATE sleep PA[16]
54 SCK / D13 D13 GPIO, SPI SCK Pin can wake from HIBERNATE sleep PA[18]

Most pins can use INPUT_PULLUP or INPUT_PULLDOWN in sleep modes. The exception is HIBERNATE sleep mode where

Pin D21 can only use an external hardware pull-up or pull down in HIBERNATE sleep mode. It also cannot be used to wake from hibernate sleep mode.

Pin Pin Name Description Interface MCU
17 D21 D21 GPIO, I2S RX No internal pull up or pull down in HIBERNATE sleep mode. PA[0]


Gen 2 Devices (STM32) (E-Series, Electron, Photon, and P2; does not include E404X):

  • On the Photon, P1, Electron, and E-Series you can only wake on time or WKP RISING in HIBERNATE mode.

  • GPIO are put into high impedance state before sleep. However, you can use pinMode(INPUT) to disconnect output pins on Gen 2 devices so the same code can be used for both Gen 2 and Gen 3 with HIBERNATE mode.

Cellular Devices (B-Series SoM, Tracker SoM, Tracker One, Boron, E404X, E-Series, and Electron):

  • On cellular devices, the cellular modem is turned off in HIBERNATE mode. This reduces current consumption but increases the time to reconnect. Also, you should avoid any HIBERNATE period of less than 10 minutes on cellular devices. Since the cellular modem needs to reconnect to the cellular network on wake, your mobile carrier may ban your SIM card from the network for aggressive reconnection if you reconnect more than approximately 6 times per hour.