sleep() [ Sleep ]

SystemSleepConfiguration

SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP)
      .gpio(D2, RISING);
SystemSleepResult result = System.sleep(config);

Since 1.5.0:

System.sleep() can be used to dramatically improve the battery life of a Particle-powered project.

For introduction to sleep and the various sleep modes and trade-offs, see Learn more about sleep modes.

The SystemSleepConfiguration class configures all of the sleep parameters and eliminates the previous numerous and confusing overloads of the System.sleep() function. You pass this object to System.sleep().

For earlier versions of Device OS you can use the classic API.

The Tracker One and Tracker SoM have an additional layer of sleep functionality. You can find out more in the Tracker Sleep Tutorial and TrackerSleep API Reference.