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.