Tag Archives: XBee

Trouble with XBee (Series 2) sleep mode

I am currently playing with Digi XBee Series 2 (ZB) modules (bought from Sparkfun Electronics) to develop a sensor network (temperature in a first step) at home (I will soon write a more detailed article about it).

As some nodes will be powered by batteries, I have to reduce their consumption. So I was investigating the sleep modes of the XBees. I selected the “pin sleep” mode to control the sleep by the external microcontroller (an ATTiny2313). However, as soon as I activated the sleep mode (SM=1), everything stops working.

I found the first problem quickly. I had just inverted the logic of the sleep request pin (pin 9): it is active (go to sleep) high and not low! So I was able to ask the module to go to sleep and to wake up.

However, when the module wakes up, it took about 6 seconds to join the network, which is very long… After some research on the Internet (Google was not my friend this time), I found the answer on a thread on the Digi Support Forum.

When a end device on the ZigBee network is design to sleep, it is important to take care of the SP (Sleep Period) and SN (Number of Sleep Periods) on its parent device (in my case the coordinator). With the default values (SN=1 and SP=0x20), if the end device sleeps for more than 320 ms (SN * SP * 10 ms), its parent device will forget it and, when it wakes up, it will have to perform the long association process (which takes several seconds to complete). If the delay is increased (by increasing SN and SP) to a value longer than the maximum sleep period of the end device, the parent device will keep the information about its son and, when it wakes up, the association is much faster (less than a second).

It now works fine!