Class Sleep
Encapsulates ESP32 sleep functions.
Inherited Members
Namespace: nanoFramework.Hardware.Esp32
Assembly: nanoFramework.Hardware.Esp32.dll
Syntax
public class Sleep
Constructors
Sleep()
Declaration
public Sleep()
Methods
EnableWakeupByMultiPins(WakeupGpioPin, WakeupMode)
Enable wakeup using multiple pins.
Declaration
public static EspNativeError EnableWakeupByMultiPins(Sleep.WakeupGpioPin pins, Sleep.WakeupMode mode)
Parameters
Type | Name | Description |
---|---|---|
Sleep.WakeupGpioPin | pins | Combination of pins that are enabled for wakeup. |
Sleep.WakeupMode | mode | Logical mode used for wakeup to occur. |
Returns
Type | Description |
---|---|
EspNativeError | Returns ESP32 native error enumeration. |
Remarks
Only pins that are RTC connected.
EnableWakeupByPin(WakeupGpioPin, int)
Enable wakeup using a gpio pin.
Declaration
public static EspNativeError EnableWakeupByPin(Sleep.WakeupGpioPin pin, int level)
Parameters
Type | Name | Description |
---|---|---|
Sleep.WakeupGpioPin | pin | GPIO number used as wakeup source. Only pins that have RTC functionality can be used. 0,2,4,12->15,25->27,32->39 |
int | level | Analog threshold at or above which pin causes wake up, or zero if pin is not active for wakeup. |
Returns
Type | Description |
---|---|
EspNativeError | Returns ESP32 native error enumeration. |
EnableWakeupByTimer(TimeSpan)
Enable Wakeup by Timer.
Declaration
public static EspNativeError EnableWakeupByTimer(TimeSpan time)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | time | Period after which wakeup occurs. |
Returns
Type | Description |
---|---|
EspNativeError | returns ESP32 native error enumeration. |
EnableWakeupByTouchPad(int, int, byte)
Enable wakeup by Touchpad.
Declaration
public static EspNativeError EnableWakeupByTouchPad(int padNumber1, int padNumber2 = -1, byte thresholdCoefficient = 80)
Parameters
Type | Name | Description |
---|---|---|
int | padNumber1 | A valid pad number to wake up the device. |
int | padNumber2 | If a valid pad number, will be used in comibation of the first pad number. |
byte | thresholdCoefficient | Threshold coefficient for automatic calibration. Percentage from 0 to 100. Default value is 80% seems to work in most cases. |
Returns
Type | Description |
---|---|
EspNativeError | Returns ESP32 native error enumeration. |
Remarks
See GetGpioNumberFromTouchNumber(int) to understand which GPIO maps with which pad.
EnableWakeupByUart(WakeUpPort, int)
Enable wakeup by UART.
Declaration
public static EspNativeError EnableWakeupByUart(Sleep.WakeUpPort portNumber, int edgeCount)
Parameters
Type | Name | Description |
---|---|---|
Sleep.WakeUpPort | portNumber | The port to use, only COM1 and COM2 are supported. Pins MUST be properly configured for COM2 for this to work. |
int | edgeCount | The number of changes in the RX pin to wakeup the ESP. |
Returns
Type | Description |
---|---|
EspNativeError | Returns ESP32 native error enumeration. |
GetWakeupCause()
Get the cause for waking up.
Declaration
public static Sleep.WakeupCause GetWakeupCause()
Returns
Type | Description |
---|---|
Sleep.WakeupCause | Returns the wakeup cause. |
GetWakeupGpioPin()
Returns a combination of pins that caused the wakeup.
Declaration
public static Sleep.WakeupGpioPin GetWakeupGpioPin()
Returns
Type | Description |
---|---|
Sleep.WakeupGpioPin | Returns a combination of the pins that caused the wakeup. |
GetWakeupTouchpad()
Get the Touchpad which caused the wakeup.
Declaration
public static int GetWakeupTouchpad()
Returns
Type | Description |
---|---|
int | Returns TouchPad number which caused the wakeup, else None. |
StartDeepSleep()
Enter deep sleep using configured wakeup sources.
Declaration
public static void StartDeepSleep()
Remarks
After a call to this method the device enters deep sleep, a wakeup source will wake the device and the execution will start as if it was a reset. After this occurs the cause can be queried using GetWakeupCause(). Keep in mind that the execution WILL NOT continue after the call to this method. This call never returns. If no wakeup sources are configured then the device enters an indefinite sleep.
See Also
StartLightSleep()
Enter light sleep with the configured wakeup options.
Declaration
public static EspNativeError StartLightSleep()
Returns
Type | Description |
---|---|
EspNativeError | Returns ESP32 native error enumeration, ESP_ERR_INVALID_STATE if Wifi or BT is not stopped. |