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!

4 thoughts on “Trouble with XBee (Series 2) sleep mode

    1. Guillaume Post author

      In the default configuration yes. However, if you increase SP and SN on the parent of the sleeping end device (either a router or the coordinator), you can go to sleep for a much longer period without having a problem when waking up.

      Reply
  1. Sergio

    Hi, I had exactly the same problem: found your post which replicated exactly my problem and convinced me that SN/SP right setting is the solution. I also found after this DIGI’s post (find here http://www.digi.com/wiki/developer/index.php/XBee_Sleeping_Problems as the link to the page into your post is not longer available 😉 for a deep dive in the logic and values for right setting SN/SP in parents’s nodes.
    Thanks for your post.
    KR
    Sergio

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *