I use Xbee in my project with arduino. I have set up Xbee configuration(i can send massge in xctu serial consol), but i have problems with arduino code. I try to use "SoftwareSerial" library, but it doesn't work properly. For example I send data using Xctu, but Xbee connected to arduino cannot receive data. Can you please help me with receiver and transmiter arduino code? Thank you, in advance.
The code:
#include <SoftwareSerial.h>
#define rxPin 1
#define txPin 0
SoftwareSerial xbee = SoftwareSerial(rxPin, txPin);
void setup(){
xbee.begin(9600);
Serial.begin(9600);
//Serial.println("Starting XBee Comunication");
xbee.listen();
}
void loop(){
if(Serial.available()){
xbee.write(Serial.read());
}
else{
Serial.println("not available");
}
if(xbee.available()){
byte x = xbee.peek();
Serial.println(x);
}
else{
Serial.println("none to read");
}
delay(2000);
//Serial.println(rec);
}