# XBee APi master library

**URL:** <https://forums.digi.com/t/xbee-api-master-library/16238>\
**Category:** XBee & XBee Gateway\
**Tags:** arduino, xbe, ejava\
**Created:** [February 9, 2016, 9:08am UTC](https://forums.digi.com/t/xbee-api-master-library/16238 "2016-02-09T09:08:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marie](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@marie](https://forums.digi.com/u/marie)\
**Post date:** [February 9, 2016, 9:08am UTC](https://forums.digi.com/t/xbee-api-master-library/16238/1 "2016-02-09T09:08:11Z")

</div>

I’m using the xbee java library to receive datat from another xbee connected to an arduino. It seems like I got some thing but itn’t clear can any one give somme help to read the data ?  
this is the java code:  
import org.apache.log4j.Logger;  
import org.apache.log4j.PropertyConfigurator;

import com.rapplogic.xbee.api.ApiId;  
import com.rapplogic.xbee.api.XBee;  
import com.rapplogic.xbee.api.XBeeAddress64;  
import com.rapplogic.xbee.api.XBeeException;  
import com.rapplogic.xbee.api.XBeeResponse;  
import com.rapplogic.xbee.api.XBeeTimeoutException;  
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse;  
import com.rapplogic.xbee.api.zigbee.ZNetTxRequest;  
import com.rapplogic.xbee.api.zigbee.ZNetTxStatusResponse;  
import com.rapplogic.xbee.util.ByteUtils;  
import com.rapplogic.xbee.api.zigbee.ZNetRxIoSampleResponse;  
public class collector {  
private final static Logger log = Logger.getLogger(collector.class);  
XBee xbee = new XBee();

private collector() throws Exception {

```
 try{
		xbee.open("COM4", 9600);
		System.out.println("connection successfully opened");
 }catch (Exception e){
	   System.out.println(" **Error opening XBee port: " + e + "**");
 }
 }

```

public void run() {  
try{  
// we wait here until a packet is received.  
XBeeResponse response = xbee.getResponse();  
// System.out.println("Received response " + response.toString());  
if (response.getApiId() == ApiId.ZNET\_RX\_RESPONSE) {  
// we received a packet from ZNetSenderTest.java  
ZNetRxResponse rx = (ZNetRxResponse) response;  
System.out.println("Received RX packet, option is " + rx.getOption() + ", sender 64 address is " + ByteUtils.toBase16(rx.getRemoteAddress64().getAddress()) + ", remote 16-bit address is " + ByteUtils.toBase16(rx.getRemoteAddress16().getAddress()) + ", data is " + ByteUtils.toBase16(rx.getData()));  
//payload = rx.getData();  
//int uint8 = payload & 0xFF;  
// System.out.println("Data received: ");

```
	}
}catch(Exception e){
	System.out.println("Error receiving response: " + e);
	xbee.close();	
}

```

}

```
 public static void main(String[] args) throws Exception {

		PropertyConfigurator.configure("log4j.properties");
		new collector();
	}
}	

```

and this what i got:  
packet from XBee: apiId=ZNET\_RX\_RESPONSE (0x90),length=14,checksum=0x59,error=false,remoteAddress64=0x00 0x13 0xa2 0x00 0x40 0x3d 0x02 0xa0,remoteAddress16=0x78 0x32,option=PACKET\_ACKNOWLEDGED,data=0x48 0x4f  
[2016-02-09 09:29:50,814] [XBee Packet Parser Thread] [DEBUG] [com.rapplogic.xbee.api.XBeePacketParser] Notifying API user that packets are ready

---

<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:** [February 9, 2016, 9:56am UTC](https://forums.digi.com/t/xbee-api-master-library/16238/2 "2016-02-09T09:56:10Z")

</div>

The data is in Hex. You need to convert it from Hex to ASCII if you want to read it.
