The Teensy 3.1 XBee Adapter is a versatile breakout board that facilitates the integration of a Teensy 3.1 microcontroller with an XBee wireless module. This adapter is designed to streamline the process of establishing a wireless communication link for your projects. It is commonly used in applications such as remote sensor networks, home automation, and robotics.
Pin Number | Description | Teensy 3.1 Connection | XBee Connection |
---|---|---|---|
1 | 3.3V Power Supply | 3.3V | VCC |
2 | 5V Power Supply (optional) | VIN | - |
3 | Ground | GND | GND |
4 | Transmit Data (TX) | Pin 1 (TX) | DIN |
5 | Receive Data (RX) | Pin 0 (RX) | DOUT |
6 | Request To Send (RTS) | - | RTS |
7 | Clear To Send (CTS) | - | CTS |
8 | Sleep Request (optional) | - | SLEEP_RQ |
9 | Associate Indicator (optional) | - | ASSOC |
10 | On/Sleep Indicator (optional) | - | ON/SLEEP |
#include <SoftwareSerial.h>
// Define the RX and TX pins connected to the XBee
#define XBEE_RX 10
#define XBEE_TX 11
// Set up the software serial port
SoftwareSerial xbeeSerial(XBEE_RX, XBEE_TX);
void setup() {
// Begin serial communication with the XBee at 9600 baud
xbeeSerial.begin(9600);
}
void loop() {
// Check if data is available to read from the XBee
if (xbeeSerial.available()) {
// Read the incoming byte from the XBee
char incomingByte = xbeeSerial.read();
// TODO: Handle the incoming data as required
}
// Check if data needs to be sent to the XBee
// TODO: Send data using xbeeSerial.write() or xbeeSerial.print()
}
Note: The example code provided is for an Arduino UNO and is intended to illustrate basic communication with an XBee module. For the Teensy 3.1, the hardware serial ports should be used instead of SoftwareSerial
, and the pin definitions will differ. Adjust the code accordingly for the Teensy 3.1 platform.