Problem in receiving data: xbee pro s2b - Page 1
Forum section: electronics / beginners

author: embedded.world@aol.com
author_rank: Contributor
timestamp: July 01, 2014, 11:24:19 am
content: I have to transfer data between two xbee modules wirelessly.I don't have any setup to configure xbee by x-ctuI 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:Code:void code_tx(void){/*CPU = 16MhzUart: 9600bps, 8 bits , 1 stop , no parityMCU to XBEE Pro S2b connections: Vcc, Dout,Din,Sleep,GNdRest 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);}}3. Rx code is below:Code:void code_rx(void){/*CPU = 16MhzUart: 9600bps, 8 bits , 1 stop , no parityMCU to XBEE Pro S2b connections: Vcc, Dout,Din,GNdRest 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();}}