Hi. I'm having trouble reading data from an Xbee with the Gikfun Xbee shield (https://smile.amazon.com/gp/product/B00XX6UKYE/ref=oh_aui_detailpage_o04_s00?ie=UTF8&psc=1).
When I use XCTU's serial monitors, I can communicate from one Xbee to the other, but when I try to read the data from the Xbee by using the shield, it does not work. I'm using this code, which is a basic example from Sparkfun's website:
/*****************************************************************
XBee_Serial_Passthrough.ino
Set up a software serial port to pass data between an XBee Shield
and the serial monitor.
Hardware Hookup:
The XBee Shield makes all of the connections you'll need
between Arduino and XBee. If you have the shield make
sure the SWITCH IS IN THE "DLINE" POSITION. That will connect
the XBee's DOUT and DIN pins to Arduino pins 2 and 3.
*****************************************************************/
// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)
SoftwareSerial XBee(2, 3); // RX, TX
void setup()
{
// Set up both ports at 9600 baud. This value is most important
// for the XBee. Make sure the baud rate matches the config
// setting of your XBee.
XBee.begin(9600);
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
{ // If data comes in from serial monitor, send it out to XBee
XBee.write(Serial.read());
}
if (XBee.available())
{ // If data comes in from XBee, send it out to serial monitor
Serial.write(XBee.read());
}
}
Now, since there's no documentation for the shield that I can find, I'm not sure that pin 2 is the shield's RX pin. I tried cycling through all the pins, but I still do not get any output in the serial monitor. Sometimes, if I restart my computer, reset the arduino and the shield and unplug the xbees and plug them in and start the code, I will see the first character that I type in CXTU show up on the serial monitor. That's it... Nothing else shows up no matter what I do...
If anyone could offer me some advice I would be very grateful!