11 years, 5 months ago.

do i need to configure xbee with xctu software first for interfacing with mbed?

i have two new xbee's. i am sending data wirelessly from one mbed to other mbed through xbees. but the i could not receive data. Do i need to configure the xbee id first and how??

here is the transmit code:

#include "mbed.h"

Serial xbee1(p13,p14);
 DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset
 
 
DigitalOut myled(LED3);//Create variable for Led 3 on the mbed
 
int main() { 
 
    rst1 = 0; //Set reset pin to 0
    myled = 0;//Set LED3 to 0
    wait_ms(1);//Wait at least one millisecond
    rst1 = 1;//Set reset pin to 1
    wait_ms(1);//Wait another millisecond
    int Y;
     
    while (1) {//Neverending Loop
        
        myled = 1; //Turn Led 3 Off
        
 
           printf("data %f \n\r", Y);
            xbee1.printf("%d", Y); //XBee write whatever the PC is sending
           xbee1.putc(Y);
            wait(1);
            myled = 0; //Turn Led 3 on for succcessfull communication
            wait(1);
        }
    }

1 Answer

11 years, 5 months ago.

No personal experience with xbee, but afaik that shouldnt be required. However basicly your code makes no sense, you say it should write whatever the PC is sending. However you first variable Y to the PC, as float (you really should have been getting warnings about this from the compiler, generally warnings means you made an error) while it is an int, and then you print it to the xbee, this time as a decimal number but still uninitialized, followed by putting it to the xbee, still without it having a value.

You can look here: http://mbed.org/users/4180_1/notebook/easyvr/ how you can make a serial bridge, where everything from one serial port is send to another one on the mbed (first example in that code).