Home/Support/Support Forum/Need help about Xbee Arduino Receiver source code

Need help about Xbee Arduino Receiver source code

0 votes
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 <Printers.h>
#include <XBee.h>
#include <SoftwareSerial.h>
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("Error reading packet. Error code: ");
//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
asked Jan 24, 2018 in IEEE 802.15.4 by Rio Kitsda New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
I am sorry but this is something you really need to get help with on an Arduino Coding site.
answered Jan 25, 2018 by mvut Veteran of the Digi Community (11,298 points)
...