Home  >  Support  >  Support Forum  >  Problem in receiving data: xbee pro s2b
Notice! We've recently migrated to using a new forum, we hope you enjoy it. If you are an existing member and this is your first time visiting our new forum, please reset your password to be able to sign in.

Problem in receiving data: xbee pro s2b

0 votes
I have to transfer data between two xbee modules wirelessly.
I don't have any setup to configure xbee by x-ctu
I have to configure xbee on the run with the help of microcontroller.
I am using Xbee Pro S2B.


1.Since xbee pro s2b don't let to set ""atmy" to I don't understand how to set xbee own address.

2. Below are code I have used for tx & rx.
In both codes I am able to configure xbee as per the code. I get ok reeponse from all the commands.
Tx code transmit data after that. But problem is rx don't receive data??

I have try to set different destination address of xbee's, same address but no help??


3. Tx code is below:
void code_tx(void) { /* CPU = 16Mhz Uart: 9600bps, 8 bits , 1 stop , no parity MCU to XBEE Pro S2b connections: Vcc, Dout,Din,Sleep,GNd Rest all pins on xbee are unconnected */ XBEE_PIN_WAKEUP(); wait_delay_us(20000); while( 'F' == response ) { /* send a dummy character */ xbee_uart_tx_string((u8_t *)("X")); /* guard time */ wait_delay_us(3000000); /* send AT command */ xbee_uart_tx_string(("+++")); response = xbee_response_ok_check(); if( 'T' == response ) { /* factory defaukt */ wait_delay_us(200000); xbee_uart_tx_string(("atre")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string((u8_t *)("atdh0")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string("atdlffff")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send ID address */ wait_delay_us(200000); xbee_uart_tx_string(("atid2244")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* sleep mode setting */ wait_delay_us(200000); xbee_uart_tx_string(("atsm1")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* write my address in memory */ wait_delay_us(200000); xbee_uart_tx_string(("atd70")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* write my address in memory */ wait_delay_us(200000); xbee_uart_tx_string(("atwr")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* exit AT mode */ wait_delay_us(200000); xbee_uart_tx_string(("atcn")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } /* if failed then restart */ if( 'F' == response ) { for(cnt = 0 ; cnt < 100 ; cnt++) wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US); } } /* SLEEP MODE */ XBEE_PIN_SLEEP(); while(1) { XBEE_PIN_WAKEUP(); wait_delay_us(10000); xbee_uart_tx_string(("HELLO WORLD")); XBEE_PIN_SLEEP(); wait_delay_us(4000000); } } [/CODE] 3. Rx code is below: [CODE]void code_rx(void) { /* CPU = 16Mhz Uart: 9600bps, 8 bits , 1 stop , no parity MCU to XBEE Pro S2b connections: Vcc, Dout,Din,GNd Rest all pins on xbee are unconnected */ while( 'F' == response ) { /* send a dummy character */ xbee_uart_tx_string((u8_t *)("X")); /* guard time */ wait_delay_us(3000000); /* send AT command */ xbee_uart_tx_string(("+++")); response = xbee_response_ok_check(); if( 'T' == response ) { /* factory defaukt */ wait_delay_us(200000); xbee_uart_tx_string(("atre")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string((u8_t *)("atdh0")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string("atdlffff")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send ID address */ wait_delay_us(200000); xbee_uart_tx_string(("atid2244")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* write my address in memory */ wait_delay_us(200000); xbee_uart_tx_string(("atwr")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* exit AT mode */ wait_delay_us(200000); xbee_uart_tx_string(("atcn")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } /* if failed then restart */ if( 'F' == response ) { for(cnt = 0 ; cnt < 100 ; cnt++) wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US); } } while(1) { xbee_response_check(); } } [/CODE][CODE]void code_tx(void)
{
/*
CPU = 16Mhz
Uart: 9600bps, 8 bits , 1 stop , no parity

MCU to XBEE Pro S2b connections: Vcc, Dout,Din,Sleep,GNd
Rest all pins on xbee are unconnected

*/


XBEE_PIN_WAKEUP();
wait_delay_us(20000);

while( 'F' == response )
{
/* send a dummy character */
xbee_uart_tx_string((u8_t *)("X"));

/* guard time */
wait_delay_us(3000000);

/* send AT command */
xbee_uart_tx_string(("+++"));
response = xbee_response_ok_check();

if( 'T' == response )
{
/* factory defaukt */

wait_delay_us(200000);

xbee_uart_tx_string(("atre"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send destination address */
wait_delay_us(200000);

xbee_uart_tx_string((u8_t *)("atdh0"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send destination address */
wait_delay_us(200000);

xbee_uart_tx_string("atdlffff"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send ID address */
wait_delay_us(200000);

xbee_uart_tx_string(("atid2244"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* sleep mode setting */
wait_delay_us(200000);

xbee_uart_tx_string(("atsm1"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* write my address in memory */
wait_delay_us(200000);

xbee_uart_tx_string(("atd70"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* write my address in memory */
wait_delay_us(200000);

xbee_uart_tx_string(("atwr"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* exit AT mode */
wait_delay_us(200000);

xbee_uart_tx_string(("atcn"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}


/* if failed then restart */
if( 'F' == response )
{
for(cnt = 0 ; cnt < 100 ; cnt++)
wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US);
}

}

/* SLEEP MODE */
XBEE_PIN_SLEEP();


while(1)
{
XBEE_PIN_WAKEUP();
wait_delay_us(10000);
xbee_uart_tx_string(("HELLO WORLD"));
XBEE_PIN_SLEEP();

wait_delay_us(4000000);

}


}
[/CODE]


3. Rx code is below:

void code_rx(void) { /* CPU = 16Mhz Uart: 9600bps, 8 bits , 1 stop , no parity MCU to XBEE Pro S2b connections: Vcc, Dout,Din,GNd Rest all pins on xbee are unconnected */ while( 'F' == response ) { /* send a dummy character */ xbee_uart_tx_string((u8_t *)("X")); /* guard time */ wait_delay_us(3000000); /* send AT command */ xbee_uart_tx_string(("+++")); response = xbee_response_ok_check(); if( 'T' == response ) { /* factory defaukt */ wait_delay_us(200000); xbee_uart_tx_string(("atre")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string((u8_t *)("atdh0")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send destination address */ wait_delay_us(200000); xbee_uart_tx_string("atdlffff")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* send ID address */ wait_delay_us(200000); xbee_uart_tx_string(("atid2244")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* write my address in memory */ wait_delay_us(200000); xbee_uart_tx_string(("atwr")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } if( 'T' == response ) { /* exit AT mode */ wait_delay_us(200000); xbee_uart_tx_string(("atcn")); xbee_uart_tx_data(0x0d); response = xbee_response_ok_check(); } /* if failed then restart */ if( 'F' == response ) { for(cnt = 0 ; cnt < 100 ; cnt++) wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US); } } while(1) { xbee_response_check(); } } [/CODE][CODE]void code_rx(void)
{

/*
CPU = 16Mhz
Uart: 9600bps, 8 bits , 1 stop , no parity

MCU to XBEE Pro S2b connections: Vcc, Dout,Din,GNd
Rest all pins on xbee are unconnected

*/

while( 'F' == response )
{
/* send a dummy character */
xbee_uart_tx_string((u8_t *)("X"));

/* guard time */
wait_delay_us(3000000);

/* send AT command */
xbee_uart_tx_string(("+++"));
response = xbee_response_ok_check();

if( 'T' == response )
{
/* factory defaukt */

wait_delay_us(200000);

xbee_uart_tx_string(("atre"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send destination address */
wait_delay_us(200000);

xbee_uart_tx_string((u8_t *)("atdh0"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send destination address */
wait_delay_us(200000);

xbee_uart_tx_string("atdlffff"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* send ID address */
wait_delay_us(200000);

xbee_uart_tx_string(("atid2244"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* write my address in memory */
wait_delay_us(200000);

xbee_uart_tx_string(("atwr"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}

if( 'T' == response )
{
/* exit AT mode */
wait_delay_us(200000);

xbee_uart_tx_string(("atcn"));
xbee_uart_tx_data(0x0d);
response = xbee_response_ok_check();
}


/* if failed then restart */
if( 'F' == response )
{
for(cnt = 0 ; cnt < 100 ; cnt++)
wait_fine_delay_us_timeout(WAIT_TIMER_PSC_20000_US , WAIT_TIMER_ARR_20000_US);
}

}


while(1)
{
xbee_response_check();

}


} [/CODE]
asked Jul 1 in XBee Programmable Development by aamirali New to the Community (0 points)

Please log in or register to answer this question.

Contact a Digi expert and get started today! CONTACT US
...