Xbee Arduino
Arduino Driver for Xbee
|
XBeeArduino
is an Arduino-friendly C++ wrapper for the xbee_c_library, providing a simplified interface for integrating XBee modules into Arduino projects.
xbee_c_library
as a submoduleClone the repository with its submodule:
XBeeArduino
header and source files in your Arduino project.Check out the examples/xbee_lr/xbee_lr.ino
for a basic usage example with the XBee LR.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
The XBeeArduino
class provides several methods to interact with XBee modules:
bool begin()
**: Initializes the XBee module. Returns true
if initialization is successful.bool connect()
**: Establishes a connection with the XBee module. Returns true
if the connection is successful.void process()
**: Continuously processes incoming data from the XBee module.bool disconnect()
**: Disconnects from the XBee module. Returns true
if the disconnection is successful.bool sendData(const T& data)
**: Sends data through the XBee module. The data type T
can vary depending on the use case.bool isConnected()
**: Checks if the XBee module is currently connected. Returns true
if connected.void reset()
**: Resets the XBee module to its default state.bool setLoRaApiOptions(const uint8_t options)
**: Configures specific options for LoRa communication using the provided options
.bool getLoRaDevEUI(uint8_t* devEUI, uint8_t length)
**: Retrieves the LoRa Device EUI into the provided devEUI
array.void (*onReceiveCallback_)
**: Function pointer for a callback when data is received.void (*onSendCallback_)
**: Function pointer for a callback when data is sent.void onReceiveWrapper(XBee* xbee, void* data)
**: Internal method to wrap the receive callback.void onSendWrapper(XBee* xbee, void* data)
**: Internal method to wrap the send callback.This example demonstrates how to initialize, connect, send data, and process incoming data with the XBeeArduino library.
The XBeeArduino
class constructor allows you to initialize the XBee module with either HardwareSerial
or SoftwareSerial
.
serial
**: Pointer to either HardwareSerial
or SoftwareSerial
. This determines the serial interface used for communication.baudRate
**: The baud rate for serial communication, typically 9600
or 115200
.To use the XBeeArduino
library in the Arduino IDE:
XBeeArduino
library repository.Documents/Arduino/libraries/
).#include <XBeeArduino.h>
.XBeeArduino
library.Here’s an example of how to use the XBeeArduino
library in an Arduino sketch:
This example demonstrates setting up the XBee module, processing incoming data, and sending data using the XBeeArduino
library in the Arduino IDE.