6 Replies Latest reply on Aug 31, 2016 12:48 PM by Intel Corporation

    Xbee communication with intel edison baord

    rahul147258

      Hi,'

      I want to interface "xbee  module" with Intel Edison board using Eclipse IDE writing C/C++ codes.

      my question is can u provide the application code by which I can interface the UART pins of intel Edison board with xbee UART pins,

      By which the data comes from Xbee will be received by another xbee which is present on intel Edison board.so can u provide some links or c/c++  code which should run on Eclipse IDE.

      for intel Edison board I have two xbee ampong which one will read data from  sensor node(sensor+xbee) and another will send data to faraway where another controller and xbee present.

       

       

      can anyone help me in programming .

      all will happen using c/c++ code and UARt communication.

       

       

      thanks

        • 1. Re: Xbee communication with intel edison baord
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Rahul147258,

          If you want to connect your Xbee using the shield maybe you can have a lot of issues, so I recommend you to look this: How to set XBee Serial?. If you don't have this problem ignore this recommendation.

          About helping you with your code you can look this thread: https://communities.intel.com/thread/61153, in the answer the user gives a repository that can be useful for you. You also can look to UART examples of the MRAA repository: https://github.com/intel-iot-devkit/mraa/tree/master/examples/c%2B%2B.

          I hope this information guides you to create your code.

          Regards,
          -Leonardo

          • 2. Re: Xbee communication with intel edison baord
            Flo1991

            Using a XBEE module is really simple, if you understand how they work (what may take some time....)

            First thing to know:

            If you just want to communicate between two XBEEs you can use the default settings, you only need to change the addresses:

            -both XBEEs must have the same network ID, e.g. 2001

            -XBEE1 must refer to DH and DL (destination address high and low) of the destination device (XBEE2) (this is the printed address on each XBEE, DH is the first line, DL the second)

            -XBEE2 must refer to DH and DL (destination address high and low) of the destination device (XBEE1) (this is the printed address on each XBEE, DH is the first line, DL the second)

            -I suggest to use XCTU for this configuration on a host computer (the configuration must only be done once), you can also use the commands directly:

            upm/xbee.cxx at master · intel-iot-devkit/upm · GitHub

            -after this configuration the XBEE moduls are working as a cable replacement:

            EdisonUARTTX-->UARTRX_XBEE1------>UARTTX_XBEE2-->WhateverUARTRX (maybe arduino)

            EdisonUARTRX<--UARTTX_XBEE1<------UARTRX_XBEE2<--WhateverUARTTX (maybe arduino)

             

            Second thing to know:

            You can use the API mode, with this you can do much more things:

            -easy communication with multiple XBEEs

            -build a network

            -direct interaction with XBEEs, also over the air (e.g. read adc value from XBEE over the air)

             

            For using the API mode you need to enable this mode (set AP to API Mode Without Escapes [1])

            -every XBEE refering to your network must share a common network ID, e.g. 2001

            -only one XBEE in you network must be in API mode

            -use the XCTU frame generator to generate an API-Frame (you can also implement the API for a dynamic frame generation at runtime, see

            GitHub - digidotcom/xbee_ansic_library: A collection of portable ANSI C code for communicating with Digi International's…  for C or

              xbee-api for node.js)

            -with different frames you can achieve different things

             

            So third thing to is how to use API frames:

            -generate the frame for your XBEE modules, you always need the destination address in your frame

            example frames:

            var gpio12high = new Buffer([0x7E, 0x00, 0x10, 0x17, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x40, 0xF8, 0xB5, 0x9F, 0xFF, 0xFE, 0x02, 0x50, 0x32, 0x05, 0x20]);

            var gpio12low = new Buffer([0x7E, 0x00, 0x10, 0x17, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x40, 0xF8, 0xB5, 0x9F, 0xFF, 0xFE, 0x02, 0x50, 0x32, 0x04, 0x21]);

            The first frame sets the destination XBEE modules GPIO12 to high level, the second to low level --> you can easily controll a LED over the air

             

            If you may send some text over the Air:

            var sendtext = new Buffer([0x7E, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x13, 0xA2, 0x00, 0x40, 0xF8, 0xB5, 0xA2, 0x00, 0x2B, 0x31, 0x32, 0x2C]);

            this frame sends the string "+12" to the destination XBEE, this string is put out at the TX pin of the destination module

            -->you may create a wirless thermometer

             

            for reading an adc value from another XBEE over the air you should use one of the APIs (especially for parsing the answer):

            example for frame creation:

            var frame1 = {

                type: 0x17, // xbee_api.constants.FRAME_TYPE.REMOTE_AT_COMMAND_REQUEST

                id: 0x01, // optional, nextFrameId() is called per default

                destination64: "0013a2004152b7c7",

                destination16: "fffe", // optional, "fffe" is default

                remoteCommandOptions: 0x02, // optional, 0x02 is default

                command: "IS",

                commandParameter: [] // Can either be string or byte array.

              };

             

            parse the answer:

            if(frame.remote64 == '0013a2004152b7c7' &&  frame.commandStatus==0)

              {

                  console.log("XBEE 1 ADC");

                  var adcval = frame.analogSamples.AD0;

              }

             

            This is not the complete code! For using the ADC0, it must be enabled (do this once at your configuration)

             

            One more thing to know:

            -some XBEEs are programmable, so you may modify there behavoiur directly and add some frames

            (e.g. add a frame type and the code to directly controll a display with XBEEs wireless, I never tried this so far)

             

            Some last things to know:

            -all XBEEs should have the same footprint

            -only XBEEs of one family can communicate with each other

            -you may choose the firmware to switch the XBEE family (e.g. 2,4 GHz modules may use Zigbee or 802.15.4 or DigiMesh, what depends on the firmware)

             

            What I don't know so far, someone may add this infomation:

            If several XBEEs are used, it may be possible to hop over other XBEEs in the network, means

             

            XBEE1 can reach XBEE2

            XBEE1 cannot reach XBEE3

            XBEE2 can reach XBEE3

            so XBEE3 may hop over XBEE2 to communicate with XBEE1

             

            Hope this helps

             

            Flo1991

            1 of 1 people found this helpful
            • 3. Re: Xbee communication with intel edison baord
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi guys,

               

              Great post Flo1991, We really appreciate your help.

               

              Rahul147258, try to follow the suggestion above. If you still have concerns about this, don't hesitate to post them here. We'll try to help you in any way we can.

               

              Regards,
              -Leonardo

              • 4. Re: Xbee communication with intel edison baord
                rahul147258

                Hi Flo,

                I understood whatever u typed here.

                But my concern is I have to receive data from Xbee1 to Xbee 2 In AT command and via UART communication.

                SO there is no interfere of ADC for time being.

                now on controller(Intel Edison) I have one more Xbee3 which send the data from Another UART to Xbee 4 which is with another  controller.

                u please tell me how do I program in C/C++ so that I can receive data from Xbee1(Xbee1 keeps transmiting) data  to Xbee2.

                and xbee3 will send to Xbee 4.

                 

                now Xbee 2 will receive via UART1 and Xbee3 will send to Xbee4 via UART2 of Intel Edison .remaining Xctu configuration I have done it.

                 

                thanks

                • 5. Re: Xbee communication with intel edison baord
                  Flo1991

                  Only one XBEE on the edison would be enough...

                  but if you want to use your setup the easiest solution may be another lib called libxbee3

                  This example shows the basics, what you have to do is to add a second XBEE with a second callback

                  libxbee3/main.c at master · attie/libxbee3 · GitHub

                  You may also use threads, that depends on you, some references to get started:

                  Linux Tutorial: POSIX Threads

                  C++ Multithreading

                   

                  But I suggest the following solution:

                  One XBEE on the edison for the whole communication

                  XBEE1 is on edison, XBEE2 is the sensor node, XBEE3 is another point you want to interact with

                   

                  XBEE1 receives sensordata from XBEE2, callback is fired

                  Now you can buffer data or directly send the data from XBEE1 to XBEE3

                  You should not be aware of data loss, because the XBEE modules retry communication and have an internal buffer

                   

                  Flo1991

                  • 6. Re: Xbee communication with intel edison baord
                    Intel Corporation
                    This message was posted on behalf of Intel Corporation

                    Hi Rahul147258,

                    Was Flo1991's information helpful? Did you successfully connect your devices?

                    Remember that we are here to help you if you have doubts.

                    Regards,
                    -Leonardo