Hey guys, I can't believe how far I've come in the past two weeks, from making an LED blink to setting up a simple serial wireless network! The arduino is my first foray into micro-controllers and is really a thing of beauty!
Back on point, I am currently working without sleep trying to find out why my new toy isn't working like I think it should. I am currently having trouble getting my arduino leonardo with an xbee shield and an xbee module (pro series 1) to send data via it's xbee to another xbee connected via usb breakout board to my computer.
The thing that is driving me up a wall is that it receives data via the xbee absolutely fine! Since I'm using a shield I don't think it's a circuit problem, so I suspect I must have fudged some code or missed a setting in the xbee somewhere. Speaking of code:
//Declare Variables
char inByteXbee = 0;
char outByteXbee = 0;
//Begin Serial
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
while (!Serial) {
}
}void loop() {
//Check for serial connection
if (Serial1.available() > 0) {
// store incoming data from PC Xbee
inByteXbee = Serial1.read();
// Process incoming data from PC Xbee
outByteXbee = inByteXbee + 1;
// Send outgoing data to Serial console and PC Xbee
Serial.print(outByteXbee);
Serial1.print(outByteXbee);
}
}
//Fin
So from my code you can tell that the last step of the process should be to print outByteXbee to Serial1, the leonardo's xbee. This is what is not working. Serial.print works fine, I can view it in the serial console, but Serial1.print does nothing. I initally tried it without printing to, or even begining, usb serial but when I got no ouput I added that in for debugging. I have also tried disconnecting the usb cable and running off a 9v to rule out serial interference or something. I have swapped the Xbees and it works exactly the same, data flows from pc to leonardo but no data flows back via xbee only via usb.
I also promise that I googled my brains out before I posted here, I just can't come up with the magic mix of keywords that will lead me to a solution! If anyone has any input as to why the code above wouldn't work, or why a very simple xbee setup would only work in one direction, please share!
edit: Also, prior to attempting xbee's I used wires to serial connect my leonardo to an uno, that worked fine for transmit and receive.