11 years, 4 months ago.

how to send data with xbee

Hi,

my goal is to establish a network with one xbee coordinator that is attached to an personal computer running a control algorithm and 6 xbee end devices connected to an mbed. The coordinator is configured in API mode and the end devices are configured in AT mode. Sending data from the computer via the coordinator to the different end devices and processing this data works fine. With

#include "mbed.h"
#include "m3pi.h"
#include "XBee.h"

//#include "m3pimaze.h"
#include <cmath>

// m3pi object instance from m3pimaze library (reset pin, tx pin, rx pin)
m3pi m3pi(p23,p9,p10);

#define XBEE_BAUDRATE   9600

//m3pi m3pi;
Serial xbee(p28,p27);


int main() {
    xbee.baud(XBEE_BAUDRATE);
    
    m3pi.locate(0,1);
    m3pi.printf("Test");
   //har buffer[4];
    int d = 0;
       
    while(1)
    {
          if(xbee.writeable())
          {
            xbee.putc(6); 
            wait(1000);
           }           
    }
}

I want to send data from each end device to the coordinator respectively to the computer. The data is recieved by a java program. Randomly the message is received correct or incorrect (number of databits changes from 17 to 39 and thus no data retrieval from the message is possible). To check the connection I attached the coordinator and the ent device with sparkfun explorer boards to pc and checked the connection using the x-ctu terminals. By doing this data was send correctly to the coordinator and thus the configuration of the xbee must be ok. What could I do to fix this problem?

Be the first to answer this question.