sleep() [ Sleep ]

gpio() (SystemSleepConfiguration)

SystemSleepConfiguration::gpio, gpio, SystemSleepConfiguration.gpio

// PROTOTYPE
SystemSleepConfiguration& gpio(pin_t pin, InterruptMode mode) 

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

// EXAMPLE
SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP)
      .gpio(D2, RISING);
      .gpio(D3, FALLING);

Specifies wake on pin. The mode is:

  • RISING
  • FALLING
  • CHANGE

You can use .gpio() multiple times to wake on any of multiple pins, with the limitations below.

If you are using RISING mode, then an internal pull-down, equivalent to INPUT_PULLDOWN is added to the pin before sleep. This is approximately 13K on Gen 3 devices and 40K on Gen 2 devices.

If you are using FALLING mode, then an internal pull-up, equivalent to INPUT_PULLUP is added to the pin before sleep. This is approximately 13K on Gen 3 devices and 40K on Gen 2 devices.

This pull can be an issue if you are connecting the wake pin to a voltage divider! Using CHANGE mode does not add pull and can be used to work around this. Make sure the pin is not left floating when using CHANGE.


System.sleep(SystemSleepConfiguration().mode(SystemSleepMode::STOP).gpio(GPS_INT, FALLING));

Since 3.0.0:

On the Tracker SoM, you can pass GPIO connected to the IO Expander directly to the GPIO sleep option in Device OS 3.0.0 and later.

Name Description Location
LOW_BAT_UC Fuel Gauge Interrupt IOEX 0.0
GPS_INT u-blox GNSS interrupt IOEX 0.7
WIFI_INT ESP32 interrupt IOEX 0.4

Gen 3 Devices:

  • You can wake on any pins on Gen 3 devices, however there is as limit of 8 total pins for wake.

On Gen 3 devices the location of the WKP pin varies, and it may make more sense to just use the actual pin name. You do not need to use WKP to wake from HIBERNATE on Gen 3 devices, and you can wake on either RISING, FALLING or CHANGE.

  • Argon, Boron, and Xenon, WKP is pin D8.
  • B Series SoM, WKP is pin A7 in Device OS 1.3.1 and later. In prior versions, it was D8.
  • Tracker SoM WKP is pin A7/D7.

Gen 2 Devices:

  • You can only wake on external interrupt-supported pins on Gen 2 devices. See the list in attachInterrupt.
  • On the Photon, P1, Electron, and E Series you can only wake from HIBERNATE mode using WKP RISING.
  • Do not attempt to enter sleep mode with WKP already high. Doing so will cause the device to never wake again, either by pin or time.
  • SLEEP_MODE_DEEP in the classic API defaults to allowing wake by WKP rising. This is no longer automatic and you should specify it explicitly as in the example here if you want this behavior by adding .gpio(WKP, RISING).