[Tutor] Question to Phyton and XBee

Daniel Berger bergiel at gmx.de
Wed Apr 12 10:32:51 EDT 2017


   Hello,

   thank you very much for your help. I have done a mistake during
   installation.
   I have tested the code for reading data from Xbee:

 #! /usr/bin/python
 # Import and init an XBee device
 from xbee import XBee, ZigBee
 import serial
 ser = serial.Serial('COM4', 9600)
 xbee = XBee(ser)
 while True:
     try:
         response =  xbee.wait_read_frame()
         print response
     except KeyboardInterrupt:
         break
 ser.close()

   At the moment it is not possible to get any data received by the Xbee,
   although it is possible to read the data by XCTU. I have chosen the
   following setup:
   - A TMP36-sensor is connected to an Arduino Uno
   - A Sparkfun XBee-shield with an XBee S2C is mounted on the Arduino
   (Router). The Arduino is connected to COM3.
   - COM4 is connected with a Sparkfun XBee-Explorer (USB-connection).
   Another XBee S2C is connected on the explorer. This XBee is the
   coordinator.
   If I send sensor data (sensor reading and sending to Xbee is done by
   Arduino Software) from the router to the coordinator, I'm able to read the
   data frames by XCTU and the results make sense. If I use the Python-code
   above, I did not get any data frames, although the RSSI-diodes of router
   and coordinator are blinking independently from the software (XCTU or
   Python) I use.
   For me it is not clear what is going wrong and I would be happy to get
   some help to solve the problem.

   Regards and thank you very much
   Daniel Berger




   Gesendet: Dienstag, 11. April 2017 um 21:04 Uhr
   Von: "Marc Tompkins" <marc.tompkins at gmail.com>
   An: "Daniel Berger" <bergiel at gmx.de>
   Cc: "tutor at python.org" <tutor at python.org>
   Betreff: Re: [Tutor] Question to Phyton and XBee
   On Tue, Apr 11, 2017 at 9:12 AM, Daniel Berger <[1]bergiel at gmx.de> wrote:

        Hello,

        I have installed the modules to control xbee with Python
        [2]https://pypi.python.org/pypi/XBee). Afterwards I have set the path
        variable on C:\Python27\python-xbee-master and also the
     subdirectories. To
        check, if the modules are available, I have written the code as
        recommended ([3]https://pypi.python.org/pypi/XBee)

        # Import and init xbee device
        from xbee import XBee
        import serial
        import arduino

        The interpreter gave the error message
        File "C:/Users/daniel/PycharmProjects/hardware_test/test_xbee.py",
     line 2,
        in <module>
        from xbee import XBee
        ImportError: No module named xbee

        I have done the same with
     [4]https://github.com/nioinnovation/python-xbee and
        it have the same effect.
        As I'm not very familiar with Python, I would like to know, what is
     going
        wrong and how I can find the module.


   How did you install it?  If you use the very simplest method -  "pip
   install xbee" - it should automatically take care of the path for you.



References

   Visible links
   1. mailto:bergiel at gmx.de
   2. https://pypi.python.org/pypi/XBee
   3. https://pypi.python.org/pypi/XBee
   4. https://github.com/nioinnovation/python-xbee


More information about the Tutor mailing list