XBee sleeping problems

XBee Sleeping FAQ

ZigBee

Data from Sleeping End-Device is Lost

Question: I set my ZigBee end-device to sleep and wake every 10 seconds. It should send me data (for example the IR or IC-driven I/O pin data), but nothing arrives at the gateway/destination.

Question: My micro wakes the Xbee running as ZigBee end-device, but the data I send never arrives at the gateway/destination.

Answer: One of the biggest problems beginners suffer when trying to use ZigBee sleeping end-devices is a failure to properly configure the non-sleeping parent (the router or coordinator). While at first this seems a needless complexity, it has to do with the limited resources within the parent. Literally, the parent maintains a collection of free memory (a scarce resource) to both buffer messages for the end-device to fetch upon waking, and also to guarantee that the sleeping device can hand-off a message to the parent the instant it wakes.

Now consider the scenario where 5 end-devices are sleeping, waking once each hour. The parent needs to allocate 5 separate sets of this scarce memory resource just in case all 5 wake up at the same time. Suppose 1 of the 5 fails, and is replaced. A new sixth end-device joins the parent, and now the parent has 6 separate sets of memory buffers - one set which will never be used again.

Therefore the parent (the router or coordinator) includes a Child Poll Timeout - search the XBee ZB module reference for that term. The parent overloads the meaning of the SN and SP settings, using the value (3 * SP * SN) to define the Child Poll Timeout. In our once-per-hour example, if the parent has SN * SP set to one hour, then three hours after the broken/missing device fails to have polled its parent for work, the parent frees up the resource allocated to that device. If the device later connects and tries to poll the parent for data, the parent rejects the child. If the child was trying to send data to the parent, the data is discarded ... sounds like your problem, right?

The child of course renegotiates, and if the parent has spare memory resources, then the child is again allocated a memory resource. However, unless special code within the child retries the data-send, then the data has been lost. The standard XBee 'IS' data-send is not retried - it is lost. If your micro woke the XBee and sent a data packet, then in AT mode that data has been lost without warning. In API mode, the TX Status packet should return an error (probably 0x22 = Not Joined to network). Your firmware will need to understand means your last data packet was lost, so it should be resent. Your code does not need to fixed the 'Not Joined' error. The XBee does that itself.

Example SN/SP setting for the router/parent

Below are some example values for SN/Sp to use in your 'parents'.

Expected Sleep Time SN SP Actual End-Device Timeout
default (minimum) 0x01 0x20 less than 1 second
maximum 0xFFFF 0xAF0 over 60 days
5 seconds 0x01 0x1F4 15 seconds
28 seconds 0x01 0xAF0 84 seconds
1 minute 0x03 0x7D0 3 minutes
5 minute 0x0F 0x7D0 15 minutes
15 minute 0x2D 0x7D0 45 minutes
1 hours 0xB4 0x7D0 3 hours
3 hours 0x21C 0x7D0 9 hours
12 hours 0x870 0x7D0 36 hours
24 hours 0x10E0 0x7D0 3 days

Notes: