- //Sender
- #include <XBee.h>
- XBee xbee = XBee();
- void setup()
- {
- Serial.begin(9600);
- // Tell XBee to use Hardware Serial. It's also possible to use SoftwareSerial
- xbee.setSerial(Serial);
- }
- void loop()
- {
- uint8_t payload[] = { 'H', 'e', 'y' };
- XBeeAddress64 addr64 = XBeeAddress64(0x0000, 0xFFFF);
- ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
- xbee.send(zbTx);
- delay(3000);
- }
- //Receiver
- #include <XBee.h>
- XBee xbee = XBee();
- ZBRxResponse rx = ZBRxResponse();
- void setup()
- {
- Serial.begin(9600);
- Serial.println("Boot...");
- Serial1.begin(9600);
- xbee.begin(Serial1);
- }
- void loop()
- {
- xbee.readPacket();
- if (xbee.getResponse().isAvailable())
- {
- Serial.println("Got Something.");
- xbee.getResponse().getZBRxResponse(rx);
- for (int i = 0; i < rx.getDataLength(); i++)
- {
- Serial.write(rx.getData(i));
- }
- Serial.println(" ");
- }
- }
Arduino XBEE Lib Example
Posted by Anonymous on Thu 24th Mar 2016 03:02
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.