XBee API Library for Processing

Bookmark and Share

Dan Shiffman and I developed a Processing library for Digi’s XBee radios. Tom Igoe also contributed code. The library facilitates receiving multiple sample I/O packets in API mode (ATAP1) from both the 802.15.4 and Series 2 XBee radios, and returns an object that contains the analog values, digital values, sender’s address and RSSI values. We started with I/O frames because the only way to receive this information is via API mode. The ability to send remote AT commands is now included. The library has been tested on Mac OS X and Windows platforms.

DOWNLOAD

DOCUMENTATION

XBeeReader class

XBeeReader constructor takes the parent PApplet “this” and a reference to a made serial port

port = new Serial(this, Serial.list()[0], 9600);
xbee = new XBeeReader(this,port);

start() – takes in the string of your setup commands and returns a string of responses. The first command in the string must begin with AT. Any commands that follow must be separated by commas and do not use AT. There is no comma after the last command.

println("Setting up Xbee"); String response = xbee.start("ATRE,ID3333,MY89,DH0,DL0");
println("Setup response: " + response);

getXbeeReading() – returns the XBeeDataFrame object

XBeeDataFrame data = xbee.getXBeeReading();

XBeeDataFrame class

Contains the information delivered in an XBee data frame. IN THIS INITIAL EXAMPLE IT IS ONLY I/O DATA. The available methods are:

getAddress16() – returns the 16-bit transmitter address as an integer
getAddress64() – returns the 64-bit transmitter address as an long
getRSSI() – returns the RSSI reading in dBm as an integer (XBee Series 1 only)
getTotalSamples() – returns the total number of samples contained in the data frame
getDigital() – returns an array of integers that represent the current state of each digital channel with -1 indicating that the channel is not configured for digital. Use this when there is only one sample per frame.
getDigital(int n) – returns the nth sample of digital data as an array of integers with -1 indicating that the channel is not configured for digital.

getAnalog() – returns an array of integers that represents the current state of each analog channel with -1 indicating that the channel is not configured for analog. Use this when there is only one sample per frame.
getAnalog(int n) – returns the nth sample of analog data as an array of integers with -1 indicating that the channel is not configured for analog.

int addr = data.getAddress16();
int rssi = data.getRSSI();
int[] digital = data.getDigital();
int[] analog = data.getAnalog();

XBeeEvent function

This function is similar to SerialEvent. The XBeeEvent is called for you when there is data available from your XBee radio.

public void xBeeEvent(XBeeReader xbee) {
	XBeeDataFrame data = xbee.getXBeeReading();
}

18 Responses to “XBee API Library for Processing”


  • getRSSI() is only available for series 1 radios, why is that? Is there anything preventing the series 2 models from responding?

    Thanks!

    Jonathan

    • I have the same problem Jonathan, I’ve read a lot on Internet but I have still the same problem…Have you solved it?
      Thanks

  • i want xbee libary for proteus please help me
    thanks and regards,
    koko

  • Could you tell me which license “XBee API Library 1.5″ is released under? Thanks

  • I’m doing a project. I have 2 Xbee communicating wirelessly. In one, I have a sensor and also I want to measure the voltage of the battery.
    The other is connected via usb to pc.
    As I can, through processing, see the value of the two sensors? (Temperature + battery voltage)
    I can not do it!
    Thanks in advance!!!
    Anton

    • Anton, I have been having the exact same trouble…I have an XBee S1 connected to an Arduino Lillypad and an XBee S1 shield on an Arduino Uno. I would like to simply view the Serial data stream for temperature data from the Lillypad on the Serial output monitor for the Uno. Is this a problem you have resolved?
      Thanks!!
      -Daniel

  • Is there any instruction to get the VSS sample?
    data.getAnalog(); doesn’t work ;(
    Thanks again!

  • When I try this I get The package “xbee” does not exist. You must be missing a library.

    I have tried putting the xbee.jar file in a directory call ed libraries in the sketchbook folder but that does not fix it. Thanks.

  • Hi Rob;
    I use the ioSample.getSupplyVoltage(); to get the supply voltage of my Xbee sensors, but, unfortunately, it returns:
    supplyVoltage=372
    I don’t know how I have to interpret this value. When I review the frame using X-CTU, the supply voltage it is: 0x097C = 2428 (dec)…
    I am confused!
    Thanks

  • Congrats for your API… The book too seems to be very usefull, I´m thinking of buying it… Meanwhile… I have a Zigbee network that uses AT Mode… Your API supports it? I´m trying to read the data in the serial port but when I have several routers sending information they get all mixed up in the serial port…

  • Referring to Matthew’s question on Nov 29th, I have the same problem. I’ve tried with XBee library versions 1.4 and 1.5, no difference. Is the Simple_Sensor_Network processing code supposed to work, am I just doing something wrong…? It keeps complaining “No library found for com.rapplogic.xbee.api”.

    Thanks.

  • Is there any option to get the Rssi for series 2 radios? getRSSI() is only available for series 1 radios, why is that?
    Thanks in advance

  • Hello!

    I have a problem triggering digital output (like DO0) on the remote ZigBee.

    Case 1:
    I know I can trigger it like this:
    - setting digital input on the base ZigBee
    - setting digital output on the remote ZigBee (DO LOW)
    - and if configured right the input state on the base ZigBee is transferred to the digital output on remote ZigBee

    I managed to do that, but I would like to trigger it via data packets.

    Case 2:
    So I tried with setting API packets that set the digital output on the remote ZigBee. I managed to change the digital output on remote ZigBee with commands ATD0=4 (DO LOW) ATD0=5 (DO HIGH).

    DO LOW API command:
    7E 00 10 17 05 00 13 A2 00 40 08 C9 80 00 02 02 44 30 04 21

    DO HIGH API command:
    7E 00 10 17 05 00 13 A2 00 40 08 C9 80 00 02 02 44 30 05 20

    Problem:
    But the problem I have is that sometime the communication between the base and remote might be lost. And if the digital output on the remote ZigBee is set to 3,3V (DO HIGH) and the communication is lost, the digital output would stay at the 3,3V. I want it to “reset” to 0V. In “case 1″ when I tried to trigger the digital output with digital input, you can set the reset timer for that digital output (command ATT0) and it did the work (the digital input reset to value 0V), but you can’t use that in the case 2.

    Question:
    Does anybody know what is the API format of the packet to simulate case 1 – I/O line passing (case 1 data packets)?
    Do you have any other ideas how to “reset” the digital output to 0V.

  • Hi, I need a communication among telsob motes and XBee. How to do this. Is there any API is developed for this. Help in this regards is highly appreciated.

Leave a Reply




Bad Behavior has blocked 3051 access attempts in the last 7 days.