Sleep options

Sleep modes

All the nodes in a DigiMesh network can sleep, entering in a low power consumption mode. There are two types of sleep modes: asynchronous or synchronous.

Asynchronous Cyclic Sleep

Asynchronous sleep modes can be used to control the sleep state on a module by module basis. Modules operating in an asynchronous sleep mode should not be used to route data.

Synchronous Cyclic Sleep

A node in synchronous cyclic sleep mode sleeps for a programmed time, wakes up in unison with other nodes, exchanges data and synchronization messages, and then returns to sleep. All synchronized cyclic sleep nodes enter and exit a low power state at the same time. This forms a cyclic sleeping network. While asleep, it cannot receive RF messages, neither will it read commands from the UART port.

Sleep parameters

There are some parameters involved in setting a node to sleep.

Sleep Mode

Sets the sleep mode for a module. Waspmote supports the following modes:

  • 0: Normal Mode. The node will not sleep. Normal mode modules are not compatible with nodes configured for sleep. Excepting the case of adding a new node to a sleep-compatible network, a network should consist of either only normal nodes or only sleep-compatible nodes.

  • 1: Asynchronous Pin Sleep Mode: Pin sleep allows the module to sleep and wake according to the state of the Sleep_RQ pin (pin 9). When Sleep_RQ is set high, the module will finish any transmit or receive operations and enter a low-power state. The module will wake from pin sleep when the Sleep_RQ pin is set low.

  • 7: Synchronous Sleep Support Mode. The node will synchronize itself with a sleeping network but will not sleep. They are especially useful when used as preferred sleep coordinator nodes and as aids in adding new nodes to a sleeping network.

  • 8: Synchronous Cyclic Sleep Mode. The node sleeps for a programmed time, wakes in unison with other nodes, exchanges data and sync messages, and then returns to sleep.

Example of use:

xbeeDM.setSleepMode(8); // Set Sync Cyclic Sleep Mode
xbeeDM.getSleepMode(); // Get the Sleep Mode used

Related variables:

xbeeDM.sleepMode → stores the sleep mode in a module

Sleep mode example:

Cyclic sleep mode example:

Sleep period

When setting the XBee module to a synchronous cyclic sleep mode, this parameter determines how long a node will sleep per period, with a maximum 4 hours (SP parameter). In the parent, it determines how long it will buffer a message for the sleeping device. Time in units of 10 ms represented in hexadecimal. Range: 1 - 1440000 (x 10 ms).

SP values example:

2 seconds: 0x0000C8 (default value) 5 seconds: 0x0001F4 10 seconds: 0x0003E8 15 seconds: 0x0005DC 4 hours: 0x15F900

Example of use:

uint8_t asleep[3]={0x15,0xF9,0x00};
xbeeDM.setSleepTime(asleep); // Set Sleep period to 4 hours

Related variables:

xbeeDM.sleepTime // stores the sleep period the module will be sleeping

Time before sleep

When setting the XBee module to a synchronous cyclic sleep mode, this parameter determines the time a module will be awake waiting before sleeping (ST parameter). It resets each time data is received via RF or serial. Once the timer expires, the device will enter low-power state. Time in units of ms represented in hexadecimal. Range: 0x45-0x36EE80.

ST values example:

2 seconds: 0x0007D0 (default value) 5 seconds: 0x001388 10 seconds: 0x002710 15 seconds: 0x003A98 1 hour: 0x36EE80

Example of use:

uint8_t awake[3]={0x36,0xEE,0x80};
xbeeDM.setAwakeTime(awake); // Set time the module remains awake: 1hour

Related variables:

xbeeDM.awakeTime // stores the time the module remains awake

Sleep options

It configures options for sleeping modes. Possible values are read as a bitmask (Bit 0 and Bit 1 cannot be set at the same time).

For synchronous sleep modules, the following sleep options are defined:

  • bit 0: Preferred sleep coordinator. The node always acts as sleep coordinator

  • bit 1: Non-sleep coordinator. Node never acts as a sleep coordinator

  • bit 2: Enable API sleep status messages

  • bit 3: Disable early wake-up for missed synchronizations

  • bit 4: Enable node type equality

  • bit 5: Disable coordinator rapid synchronization deployment mode. For asynchronous sleep modules, the following sleep options are defined:

  • bit 8: Always wake for ST time

Example of use:

xbeeDM.setSleepOptions(0x01); // Set the node to be the preferred sleep coordinator

Related variables:

xbeeDM.sleepOptions // stores the sleep option chosen