# Example that will produce errors

**URL:** <https://forums.digi.com/t/example-that-will-produce-errors/3396>\
**Category:** Python\
**Created:** [September 7, 2009, 2:42pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396 "2009-09-07T14:42:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkats](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vkats](https://forums.digi.com/u/vkats)\
**Post date:** [September 7, 2009, 2:42pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/1 "2009-09-07T14:42:02Z")

</div>

Hello,

I an running the following example on the ‘‘ConnectPort X4’’. My purpose is to get temperature, humidity battery level from remote sensors.

# import zigbee and xbee\_sensor modules:

import zigbee  
import xbee\_sensor

# configure known destination:

DESTINATION=“[00:13:a2:00:40:31:ab:67]!”

# ensure sensor is powered from adapter:

zigbee.ddo\_set\_param(DESTINATION, ‘D2’, 5)  
zigbee.ddo\_set\_param(DESTINATION, ‘AC’, ‘’)

# get and parse sample:

sample = zigbee.ddo\_get\_param(DESTINATION, ‘IS’)  
xbee\_temp = xbee\_sensor.XBeeWatchportT()  
xbee\_temp.parse\_sample(sample)  
print “Temperature is: %f degrees Celsius” % (xbee\_temp.temperature)

The code is stored on the X4 and executed with the python command, the result is:  
Traceback (most recent call last):  
File “”, line 7, in ?  
File “WEB/python/xbee\_sensor.py”, line 65, in ?  
from devices.device\_base import DeviceBase  
ImportError: No module named devices.device\_base

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [September 8, 2009, 3:00pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/2 "2009-09-08T15:00:26Z")

</div>

Just as a side note - you can’t run Dia modules without Dia running. For example if you look into the dia.py file you see how it splices the ZIP into the OS by the sys.path.insert() and other details. Without this splice you’ll get a ‘no module’ error for every module called.

Your example makes no sense in a Dia context, as you’d NOT be calling ddo\_set\_param() and so on. Plus assuming your sensors sleep, then you cannot issue DDO to them, nor can you poll them for values.

That is the value of Dia - the complexities it forces on you help solve the fact that (as example) my temperature sensors send me a new value only every 15 minutes. In between those 15 minutes, any attempt to talk to that sleeping sensor just cripples my system for up to 30 seconds. I am forced to just let Dia collect the data for me, and them I have a temperature WITH a time-stamp which shows me what the historical value was.

---

<div class="post-metadata">

**Author:** ![52637p](https://avatars.discourse-cdn.com/v4/letter/5/c6cbf5/32.png) [@52637p](https://forums.digi.com/u/52637p)\
**Post date:** [September 8, 2009, 4:12am UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/3 "2009-09-08T04:12:56Z")

</div>

Is there more to your sample than what you’ve posted? A very naive reading of the code and the error would indicate an attempt to use a component of the iDigi Dia source without building a complete Dia “application” using the Dia make.py script, etc. I would expect the devices module dependence to be made resolved in a dia.zip file, for instance.

---

<div class="post-metadata">

**Author:** ![vkats](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vkats](https://forums.digi.com/u/vkats)\
**Post date:** [September 8, 2009, 8:25am UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/4 "2009-09-08T08:25:57Z")

</div>

Thank 52637p for your reply.  
I repeated the procedure using the make.py the result was:

C:\iDigi\_Dia\>python make.py Vag2.py  
Analyzing files…  
Compiling files…  
Zipping files…  
Finished writing archive bin/dia.zip  
Adding ‘Vag2.py’ as ‘dia.yml’…

I loader this new dia.zip to X4 and executed the Vag2.py example.

The result was:

Traceback (most recent call last):  
File “”, line 7, in ?  
ImportError: No module named xbee\_sensor

Obviously there is a problem with the library I am using.  
Any ideas on how I can run this example?

---

<div class="post-metadata">

**Author:** ![52637p](https://avatars.discourse-cdn.com/v4/letter/5/c6cbf5/32.png) [@52637p](https://forums.digi.com/u/52637p)\
**Post date:** [September 8, 2009, 3:37pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/5 "2009-09-08T15:37:45Z")

</div>

Oh, it’s not a side note at all. The key is definitely that there is a mixing of terms in the sample. A visit to the resources area on [idigi.com](http://idigi.com) may be helpful… there are documents with a few XBee related samples to serve as reference.

---

<div class="post-metadata">

**Author:** ![vkats](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vkats](https://forums.digi.com/u/vkats)\
**Post date:** [September 8, 2009, 3:46pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/6 "2009-09-08T15:46:31Z")

</div>

Ok I uploaded the xbee\_sensor.py file directly to the X4.  
The error message that I get I believe is no more library related. It now changed to:

Traceback (most recent call last):  
File “”, line 15, in ?  
Exception: ddo\_get\_param: error fetching DDO parameter.

This is an example from the manual!!!

---

<div class="post-metadata">

**Author:** ![lynnl](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lynnl](https://forums.digi.com/u/lynnl)\
**Post date:** [September 8, 2009, 5:02pm UTC](https://forums.digi.com/t/example-that-will-produce-errors/3396/7 "2009-09-08T17:02:46Z")

</div>

This just means there was no response.

If your sensor is sleeping, you’ll always get that response since a sleeping node doesn’t see requests.

It also happens if the MAC address is unknown or the node is not connected/associated.
