xbee api mode help!!


i have 2 xbees 1 configured coordinator api , configured router api.

i have attached 2 xbees 2 arduinos , test communication between them have simple code

code in arduino hooked coordinator xbee

description: check button press. upon press send zigbee transmit request frame.


int button1 = 3;


void setup(){

pinmode(button1, input);

serial.begin(9600);
 
}

void loop(){
 
 
if (digitalread(button1) == high){

senddata();

 
}


}



void senddata(){
 
 
  serial.write(0x7e);
 
  serial.write(0x00);
  serial.write(0x16);
 
  serial.write(0x10);
 
  serial.write(0x01);
 
 
  serial.write(0x00);
  serial.write(0x13);
  serial.write(0xa2);
  serial.write(0x00);
  serial.write(0x40);
  serial.write(0x8c);
  serial.write(0xc6);
  serial.write(0xd4);
 
 
  serial.write(0x20);
  serial.write(0x01);
 
 
  serial.write(0x00);
 
 
  serial.write(0x00);
 

//data start 
  serial.write(0x54);
  serial.write(0x78);
  serial.write(0x44);
  serial.write(0x61);
  serial.write(0x74);
  serial.write(0x61);
  serial.write(0x30);
  serial.write(0x41);
 
  serial.write(0x13);
 
 
   
 
  delay(10);
 
 
 
 
}


next code arduino hooked router xbee.

description: scans "0x54" byte , if there lights led. can see coordinator sends byte 0x54 along other bytes.


int bell = 5;

void setup(){

  pinmode(bell, output);

  serial.begin(9600);


}


void loop(){



  if(serial.available() >= 25){


    if(serial.read() == 0x7e){


      for(int i=0;i<24;i++){

        if(serial.read() == 0x54)
        {

          digitalwrite(bell, high);

        }

      }




    }


  }


}


i add when turn on serial monitor when press button serial monitor displays correctly data passed tx lights up. assumption problem in router not getting data rather coordinator not sending data. have been trying hunt problem couple of hours no success. highly appreciated!

quote
i have attached 2 xbees 2 arduinos , test communication between them have simple code

maybe need use rubber bands, rather duct tape.

if connecting xbees arduinos in reasonable way, describe is. specifically, how xbee gets data from/sends data to, arduino , lights device has.

the sender sends 26 bytes. receiver waits 25 bytes , reads 25. why? after first packet, you're out of sync.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > xbee api mode help!!


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62