# Need help about Xbee Arduino Receiver source code

**URL:** <https://forums.digi.com/t/need-help-about-xbee-arduino-receiver-source-code/19056>\
**Category:** XBee - 802.15.4\
**Tags:** arduino-xbee, xbees2, receiver, transmitter, xbee\
**Created:** [January 24, 2018, 3:24pm UTC](https://forums.digi.com/t/need-help-about-xbee-arduino-receiver-source-code/19056 "2018-01-24T15:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rio\_Kitsda](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rio\_Kitsda](https://forums.digi.com/u/Rio_Kitsda)\
**Post date:** [January 24, 2018, 3:24pm UTC](https://forums.digi.com/t/need-help-about-xbee-arduino-receiver-source-code/19056/1 "2018-01-24T15:24:09Z")

</div>

Excuse me, i am newbie and i need some help about receiver code for my Xbee Coordinator API. i am using Xbee S2.

this is my source code from Xbee Router as Transmitter.

#include  
#include  
#include  
int ledPin = 13;  
int EP =9;  
XBee xbee = XBee();  
SoftwareSerial Xbee(0,1);  
uint8\_t payload[]={0,0,0,0,0,0,0,0,0,0};  
XBeeAddress64 addr64 = XBeeAddress64(0x00000000,0x00000000);  
//create packet  
ZBTxRequest tx = ZBTxRequest(addr64, payload, sizeof(payload));  
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

void setup() {  
pinMode(ledPin, OUTPUT);  
pinMode(EP, INPUT); //set EP input for measurment  
Serial.begin(9600); //init serial 9600  
}

void loop() {  
// put your main code here, to run repeatedly:

payload[0]=‘G’;  
payload[1]=‘E’;  
payload[2]=‘T’;  
payload[3]=‘A’;  
payload[4]=‘R’;  
payload[5]=‘|’;  
xbee.send(tx);  
long measurement =TP\_init();  
delay(50);  
// Serial.print("measurment = ");  
Serial.println(measurement);  
if (measurement \> 1000){  
digitalWrite(ledPin, HIGH);  
}  
else{  
digitalWrite(ledPin, LOW);  
}

if (xbee.readPacket(500)) {  
// got a response!

```
// should be a znet tx status              
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
  xbee.getResponse().getZBTxStatusResponse(txStatus);
}

```

} else if (xbee.getResponse().isError()) {  
[//nss.print](https://nss.print)("Error reading packet. Error code: ");  
[//nss.println](https://nss.println)(xbee.getResponse().getErrorCode());  
}

}

long TP\_init(){  
delay(10);  
long measurement=pulseIn (EP, HIGH); //wait for the pin to get HIGH and returns measurement  
return measurement;  
}

My Xbee Coordinator API always sending frames log ‘IO Data Sample RX Indicator’.  
can someone help me make the receiver code for my Xbee Coordinator API based on my Transmitter code? thanks

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [January 25, 2018, 2:43pm UTC](https://forums.digi.com/t/need-help-about-xbee-arduino-receiver-source-code/19056/2 "2018-01-25T14:43:19Z")

</div>

I am sorry but this is something you really need to get help with on an Arduino Coding site.
