没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > xbee-arduino |
xbee-arduino
|
1 | 0 | 29 |
贡献者 | 讨论 | 代码提交 |
OverviewThis is an Arduino library for communicating with XBees in API mode, with support for both Series 1 (802.15.4) and Series 2 (ZB Pro/ZNet). This library Includes support for the majority of packet types, including: TX/RX, AT Command, Remote AT, I/O Samples and Modem Status.
News11/14/09 Version 0.2.1 is available. This release contains a bug fix for Remote AT 10/26/09 XBee-Arduino 0.2 is now available. This release adds support for AT Command, Remote AT, and I/O sample (series 1 and 2) packets. Along with this release I have created several new examples. 8/09/09 I have released Droplet, a wireless LCD display/remote control with support for Twitter, Google Calendar, weather etc. It uses this software to send and receive XBee packets. 4/19/09 Release 0.1.2: In this release I added some abbreviated constructors for creating basic Requests and get/set methods to facilitate the reuse of Requests 3/29/09 Initial Release InstallationArduino 16 (or earlier):
Download the zip file, extract and copy the XBee folder to ARDUINO_HOME/hardware/libraries If you are upgrading from a previous version, be sure to delete XBee.o
Arduino 17 (or later):
Determine the location of your sketchbook by selecting "preferences" on the Arduino menu. Create a "libraries" folder in your sketchbook and unzip the download there. See this for more information.
DocumentationAPI docs
ExampleI have created several sketches of sending/receiving packets with Series 1 and 2 XBee radios. You can find these in the examples folder. Here's an example of sending a packet with a Series 2 radio:
#include
// Create an XBee object at the top of your sketch
XBee xbee = XBee();
// create an array for holding the data you want to send. You can change the contents of your array later on in the loop.
uint8_t payload[] = { 'X', 'B', 'e', 'e' };
// Specify the address of the remote XBee (this is the SH + SL)
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x403e0f30);
// Create a TX Request
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
// Create a Status Response object
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
// Tell XBee to start Serial
void setup() {
xbee.begin(9600);
}
void loop() {
// Send your request
xbee.send(zbTx);
// We'll wait up to five seconds for the status response. If the receiving XBee is powered on, the response will
// arrive very quickly, but if the remote XBee is not powered on or associated it could take a few seconds for a response.
if (xbee.readPacket(5000)) {
// Got a response!
// Should be a ZB TX Status
if (xbee.getResponse().getApiId() ZB_TX_STATUS_RESPONSE) {
// It is, now get the status response
xbee.getResponse().getZBTxStatusResponse(txStatus);
// Check if it was delivered
if (txStatus.getDeliveryStatus() SUCCESS) {
// Packet was successfully delivered
} else {
// The remote XBee did not receive our packet. is it powered on?
}
}
}
}Optionally you can connect your receiving XBee to your computer and use XBee API to receive the packets. There are more examples in the download.
To add XBee support to a new sketch, add "#include " (without quotes) to the top of your sketch. You can also add it by selecting the "sketch" menu, and choosing "Import Library->XBee".
Uploading SketchesThe Arduino has only one serial port which must be connected to USB (FTDI) for uploading sketches and to the XBee for running sketches. The Arduino XBee Shield provides a set of jumpers to direct Serial communication to either the USB (Arduino IDE) or the XBee. When using the XBee Shield you will need to place both the jumpers in the USB position prior to uploading your sketch. Then after a successful upload, place the jumpers in the "XBEE" position to run your sketch. Always remember to power off the Arduino before moving the jumpers.
HardwareI recommend the XBee Shield for interfacing with Arduino. Of course you'll also need an XBee radio, either series 1 or series 2. Here's a series 1 radio
For interfacing with Arduino clones that are not shield compatible, such as Modern Device's RBBB, you will need 3.3V power and logic shifter or voltage divider to convert Arduino's 5V to an XBee safe 3.3V. For more info, see Thomas Ouellet Fredericks' AXIC.
ConfigurationTo use this library your XBee must be configured in API mode (AP=2). Take a look at this for information on configuring your radios to form a network.
Feature SupportSeries 1 and 2AT_COMMAND_REQUEST 0x8 AT_COMMAND_RESPONSE 0x88 REMOTE_AT_REQUEST 0x17 REMOTE_AT_COMMAND_RESPONSE 0x97 MODEM_STATUS_RESPONSE 0x8a Series 1 (802.15.4)TX_64_REQUEST 0x0 TX_16_REQUEST 0x1 TX_STATUS_RESPONSE 0x89 RX_64_RESPONSE 0x80 RX_16_RESPONSE 0x81 RX_64_IO_RESPONSE 0x82 RX_16_IO_RESPONSE 0x83 Series 2 (ZB Pro/ZNet)ZB_TX_REQUEST 0x10 ZB_RX_RESPONSE 0x90 ZB_TX_STATUS_RESPONSE 0x8b ZB_IO_SAMPLE_RESPONSE 0x92 Other MicrosNot using Arduino? It should be easy to port this library to any microcontroller that supports C++ and serial available/read/write/flush. The only other dependency is the millis() function for milliseconds.
SupportPlease report any bugs on the Issue Tracker.
Questions/FeedbackQuestions about this project should be posted to http://groups.google.com/group/xbee-api?pli=1 For all other stuff, I can be contacted at andrew.rapp at gmail.