Hi, I've been trying for the last couple of days to make an Xbee network. My problem is that even if i followed the guide on arduino to connect both of my xbee version 2, with 2 arduino, one with the program that lights led 13 when an H is received, the other that send H and L every 1 second. I have many problems:
1- sometime my program does not send H and L automatically, I have to first open up a terminal and then it starts sending. I am assuming that the Tx light blink every time it sends an H, even if a terminal is not opened on the computer.
2- The other xbee just does not blink.
What I've done:
I am able to configure the xbee, and i've set them with the good configuration, as written in the guide.
I am setting both xbee to xbee mode, on both pins.
Both xbee are connected to the same computer
What I've tried:
Using default values, thereofre DH and DL are both at 0. ID at 324.
Using custom values: DH at 0, DL at FFFF
Using custom values: DH at the SH of the other xbee, DL at the SL of the other xbee
Nothing worked. Also, I've noticed that sometime when I plug the arduino in the computer, I does not always respond. Sometime I need to disconnect, reconnect.
My final goal that i want to do with the Xbee and arduino is:
connect an hardware, via USB to one arduino(do i need to put it in usb mode)
connect the other arduino to a computer and use a program to read the serial data received via COM.
Therefore it is kinda a wireless USB transfer.
You need to configure DH and DL of each xbee with SH and SL of the other one. what version do you have?
DH1 = SH2
DL1 = SL2
DH2 = SH1
DL2 = SL1
Same channel and pan id.
It should work fot transparent mode. You have to send data by serial: Serial.print();
If you want to use API mode, then you have to set DH and DL at 0 on both modules. Also AP needs to be at 1 or 2. I just tried AP = 2.
I had a similar problem using API mode, they started working when I updated their firmware to the latest version. Also, restoring xbee sometimes helps.
About replug arduino... I have to do that sometimes with my arduino uno. Sometimes windows doens't recognize it but arduino uno takes power from usb anyway. In ubuntu I didn't find this problem.
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}