hello can someone help me to communicate two xbee using arduino? i have tried some coding and some xbee configurations, but its not working. would someonehelp me?
btw i use xbee pro s3b.
Generally the XBee modules need to be in API mode 1 for the Arduino libraries to work. You also need to be using the Digi Mesh firmware versions.
thanks for your replying,
I have made code like this:
- RECEIVER
#include <SoftwareSerial.h>
SoftwareSerial xbee(2,3);
String perintah_string;
String perintah;
void setup() {
Serial.begin(9600);
xbee.begin(9600);
}
void loop() {
while(xbee.available()>0){
char perintah_char = xbee.read();
perintah_string += perintah_char;
perintah_string.trim();
if(perintah_string.length()>0){
perintah = perintah_string;
Serial.println(perintah);
Serial.println(perintah_string);
perintah = "";
perintah_string = "";
}
}
}
- TRANSMITTER
#include<SoftwareSerial.h>
SoftwareSerial xbee(2,3);
void setup()
{
Serial.begin(9600);
xbee.begin(9600);
}
void loop()
{
xbee.write("HELLO");
Serial.println("HELLO");
delay(1000);
}
And the wiring is like this for both xbee’s:
Actually i use xbee shield for this, so i make wiring like this on xbee shield:
RX ==> 2(ARDUINO)
TX ==> 3(ARDUINO)
GND ==> GND (ARDUINO)
5V ==> 5V(ARDUINO)
and I have also tried to reverse the rx and tx pins, like RX ==> 3 and TX ==> 2, but no results.
so how should i solve it?
If I may suggest, remove the XBee hardware from the Arduino. Then run jumper wires from the Tx of board 1 to Rx of board 2. Then do the same the other direction. Just get your code to send data from one to the other using these ports.