My goal is to be able receive and print text that is sent from a Yun, through a XBee S2 coordinator to a XBee S2 end device which is connected to a pro-mini.
So far, sending sensor values or text via serial from the pro-mini to the Yun through the XBees has worked fine. For some reason(s) my attempts to communicate in the other direction have failed.
Any suggestions or guidance would be greatly appreciated.
My configuration and what is working.
Coordinator--picture of setup below
Arduino Yun
XBee shield
Xbee S2 Coordinator AT Mode
End Device--picture below
Pro-mini(5v 16mhz) mounted to proto board
Sparkfun XBee regulated beakout board mounted to same proto board
XBee S2 End Device AT Mode
Sparkfun FTDI basic used for USB connection to PC
The XBees were setup using XCTU in following with TunnelsUP and Robert Faludi's tutorials. Basically I selected matching PAN Ids and loaded the most recent Coordinator AT and End device AT firmware.
Here is what works on the YUN side. This is thanks to PaulS from the forum.
char inData[64];
byte index;
boolean started = false;
boolean ended = false;
#include <SoftwareSerial.h>
// XBee's DOUT (TX) is connected to pin 10 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX)
SoftwareSerial XBee(10, 11); // RX, TX
void setup()
{
Serial.begin(9600);
XBee.begin(9600);
}
void loop()
{
while (XBee.available() > 0)
{
char aChar = XBee.read();
if(aChar == '<')
{
started = true;
index = 0;
inData[index] = '\0';
}
else if(aChar == '>')
{
ended = true;
}
else if(started)
{
inData[index] = aChar;
index++;
inData[index] = '\0';
}
}
if(started && ended)
{
Serial.println(inData);
// Get ready for the next time
started = false;
ended = false;
index = 0;
inData[index] = '\0';
}
}
And on the Pro-mini side anything like this works.
void Setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println("<Hello World>");
delay(1000);
}
The above example successfully sends the text to the YUN which is displayed in the COM port.
Now, what does NOT work is.
On the pro-mini side.
char inData[64];
byte index;
boolean started = false;
boolean ended = false;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while (Serial.available() > 0)
{
char aChar = Serial.read();
if(aChar == '<')
{
started = true;
index = 0;
inData[index] = '\0';
}
else if(aChar == '>')
{
ended = true;
}
else if(started)
{
inData[index] = aChar;
index++;
inData[index] = '\0';
}
}
if(started && ended)
{
Serial.println(inData);
// Get ready for the next time
started = false;
ended = false;
index = 0;
inData[index] = '\0';
}
}
And on the YUN side.
#include <SoftwareSerial.h>
SoftwareSerial XBee(10,11);
void setup()
{
XBee.begin(9600);
Serial.begin(9600);
}
void loop()
{
XBee.println("<Hello World>");
delay(1000);
}
I've tried many different approaches to solving this to no avail. I've tried wiring the xbee breakout board's DIN and DOUT directly to the mini's RX/TX and TX/RX just for good measure. I didn't think that would work, but I tried anyway. I also tried wiring DIN and DOUT to available digital pins on the mini. Then established a SoftwareSerial instance in the code for those pins. No luck.
I know I'm missing something, but not sure what.
Any thought? Thank you for reading.