Arm Mbed OS support forum

Communication between two Xbee pro s1

Hi I am trying to establish wireless communication between two mbed LPC1768 using Xbee pro s1 but I am really struggling.
This is the transmitting part, I am reading from pc com port and transmit the data.

#include "main.h"
#include "xbee.h"

xbee xbee2(p9,p10,p11); //Initalise xbee_lib

Serial pc(USBTX, USBRX);

//SHOWING SENDING STATUS
BusOut sending_status(LED1,LED2,LED3,LED4);

int main() {

    char send_data[202]; //Xbee buffer size is 202 bytes
    char read_data[202]; //Xbee buffer size is 202 bytes

    while (1) {

            int i = 0;
            if(pc.readable()) {
                pc.scanf("%s", send_data);
                xbee2.SendData(send_data); //Send data to XBee
               //xbee1.RecieveData(read_data,0); //Read data from the XBee
               //pc.printf("You said:%s",read_data);
           
                 sending_status = 1 << (i++ % 4);
            
                 wait(1.0);
               }
       }
}

and this is receiving data, after recieving, I display to the lcd

#include "mbed.h"
#include "uLCD_4DGL.h"
#include "xbee.h"

xbee xbee1(p9,p10,p11); //Initalise xbee_lib

DigitalOut myled(LED1);
DigitalOut myled2(LED2);

uLCD_4DGL uLCD(p28,p27,p29); // serial tx, serial rx, reset pin;
//Serial pc(USBTX,USBRX);

int main() {
    
    uLCD.cls();
   // string name;
    uLCD.background_color(BLACK);
    uLCD.baudrate(3000000);
    uLCD.printf("%This is a test");
    

   char send_data[202]; //Xbee buffer size is 202 bytes
   char read_data[202]; //Xbee buffer size is 202 bytes

    while (1) {

       
           myled = !myled;
            
           xbee1.RecieveData(read_data,0); //Read data from the XBee
           uLCD.printf("Received data %s", read_data);
            
           myled = !myled;
          }
}

Thanks in advance.

Please use code blocks. Triple backticks before and after your code.

```
// your code after triple backticks
#include "main.h"
#include "xbee.h"

xbee xbee2(p9,p10,p11); //Initalise xbee_lib

Serial pc(USBTX, USBRX);

//SHOWING SENDING STATUS
BusOut sending_status(LED1,LED2,LED3,LED4);

int main() {

  char send_data[202]; //Xbee buffer size is 202 bytes
  char read_data[202]; //Xbee buffer size is 202 bytes

  while (1) {

    int i = 0;
    if(pc.readable()) {
        pc.scanf("%s", send_data);
        xbee2.SendData(send_data); //Send data to XBee
        sending_status = 1 << (i++ % 4);
        wait(1.0);
    }
  }
}
// close the code block by placing triple backticks
```

Like the way I just did?

Hi @pimani
I edited your post to put the code inside a code block (using three ~~~ characters before and after the code)
Could you elaborate what you are struggling with? This doesn’t seem to be related to Mbed TLS. If it is Mbed TLS related, please share the Mbed TLS logs in your connection
Regards,
Mbed Support
Ron

Hi Ron, I appreciate your help. My problem is, I am trying to establish a wireless mbed LPC1768 using Xbee pro s1 but it doesn’t work and this stress me a lot. the first mbed LPC1768 process data from sensor, then send them using Xbee. The sencond one receive the data using Xbee then process and display it on lcd. Is the problem in the coding or hardware? is there a specific library for Xbee you would recomend?

Any help will be appreciate
Pac