# XBEE in sleep mode from Python app

**URL:** <https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475>\
**Category:** Python\
**Tags:** micropython\
**Created:** [June 9, 2021, 9:09am UTC](https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475 "2021-06-09T09:09:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parthasaradhi](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@Parthasaradhi](https://forums.digi.com/u/Parthasaradhi)\
**Post date:** [June 9, 2021, 9:09am UTC](https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475/1 "2021-06-09T09:09:23Z")

</div>

Hi all,  
I am trying to put XBEE 3.0 module in sleep mode through Python app. However I am getting EALREADY error. I configured XBEE to be end device using XCTU. How can I over come this error and put XBEE module in sleep mode? Thank you for your time.

RGDS  
NPS

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [June 21, 2021, 2:59pm UTC](https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475/2 "2021-06-21T14:59:23Z")

</div>

See [http://cms.digi.com/resources/documentation/digidocs/90002219/#reference/r\_sleep\_mp.htm?Highlight=Sleep](http://cms.digi.com/resources/documentation/digidocs/90002219/#reference/r_sleep_mp.htm?Highlight=Sleep)

---

<div class="post-metadata">

**Author:** ![warrenfelsh](https://avatars.discourse-cdn.com/v4/letter/w/94ad74/32.png) [@warrenfelsh](https://forums.digi.com/u/warrenfelsh)\
**Post date:** [May 17, 2022, 11:21am UTC](https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475/3 "2022-05-17T11:21:42Z")

</div>

Python sleep() will pause for an hour, day or whatever if given the proper value. It does not allow other processes take place (in same script) however. A better way is to use an event which will create an event on timeout.

Have a look at threading.Timer. It runs your function in a new thread without using sleep().

from threading import Timer

def hello():  
print “hello, world”

t = Timer(30.0, hello)  
t.start() # after 30 seconds, “hello, world” will be printed

The second method to delay would be using the implicit wait method:

driver.implicitly\_wait(5)

The third method is more useful when you have to wait until a particular action is completed or until an element is found:

self.wait.until(EC.presence\_of\_element\_located((By.ID, ‘UserName’))

[http://net-informations.com/python/pro/sleep.htm](http://net-informations.com/python/pro/sleep.htm)

---

<div class="post-metadata">

**Author:** ![anticidedretard](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@anticidedretard](https://forums.digi.com/u/anticidedretard)\
**Post date:** [August 1, 2022, 11:38am UTC](https://forums.digi.com/t/xbee-in-sleep-mode-from-python-app/22475/4 "2022-08-01T11:38:59Z")

</div>

hi guys im new here  
thanks for useful answers!
