Check if Xbee is working?

I have two S1 Xbees and 2 Arduino Unos. I went through many tutorials trying to make the xbees work. How do I verify if the Xbees are not defective and are working properly.
Can someone help me with a code that will send a value from one arduino and run a motor on the other. Then send another data from the first arduino and the motor would stop.

If you are trying to test if the XBees are working, leave the motor and anything else out, for now.

You haven’t given much information on your setup, which makes it hard to give you specific help, so here’s what I suggest.

On Uno-A use the following, but change the baud rates to whatever you have your XBees configured to and make sure the XBee is wired to the correct DIO pins. In this case Pin 2 connects to the XBee TX and Pin 3 to the XBee RX.

#include <SoftwareSerial.h>

SoftwareSerial xbee1( 2, 3 );

void setup( ) {
  Serial.begin( 9600 );
  xbee1.begin( 9600 );

  Serial.println( "Ready!" );
  
  delay( 500 );

  xbee1.write( "XBee 1 says it's ready!" );
  
}

void loop( ) {
  if( Serial.available( ) ) {
    /* If data comes in from serial monitor, send it out to XBee */
    xbee1.write( Serial.read( ) );
  }
  if( xbee1.available( ) ) {
    /* If data comes in from XBee, send it out to serial monitor */
    Serial.write( xbee1.read( ) );
  }
}

On XBee-B, connect the XBee RX to the Arduino pin 0 and the XBee TX to the Arduino Pin 1. Load the following sketch, access the XBee with XCTU (yes through the Arduino) and connect it in XCTU’s console mode.

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Open up the Arduino IDE’s serial console, connected at the same baud as the sketch for XBee-A.
You should now be able to send/receive packets from XCTU or the Arduino serial console and see it on the other.

If not, then double check your XBee configuration in XCTU.
For each XBee, restore them to factory default settings and change only the following parameters.
XBee-A
Channel : 1
PAN ID : 1234
Destination Address Low : 3434
16-bit Source Address : 4343
XBee-B
Channel : 1
PAN ID : 1234
Destination Address Low : 4343
16-bit Source Address : 3434

Then re-test as outlined above.

I hope this helps.

Cheers!

Thank you for your detailed reply. I'll do what you said and inform you if it works.
As for the project, I am making a rc car that has a lifting and gripping mechanism. I'll be using 2 servos and 2 motors. So need the xbee to communicate with them!
PS- I hv configured the Xbees using Putty terminal as shown in the Xbee tutorial on YouTube by Jeremy Blum. Hope that's not a problem!?

So need the xbee to communicate with them!

No, the XBees do NOT have to communicate with the motors or servos. And, a darned good thing, too, since that is not possible.

The XBees have to communicate with each other and with the Arduinos they are mounted on.

PS- I hv configured the Xbees using Putty terminal as shown in the Xbee tutorial on YouTube by Jeremy Blum.

That tells us the convoluted process that you used (X-CTU is far easier), but it does NOT tell us what values you assigned to what parameters. For series 1 models, PAN ID, MY and DL are all that need to be set. MY on one is DL on the other (and neither is 0x00 or 0xFF).

I connected as kamondelious said. I am able to send data from the Xbee connected to the arduino using the Serial monitor. But when I send data from the XCTU console, it does not appear on the serial. Anything wrong with my Xbees or the code?

I am able to send data from the Xbee connected to the arduino using the Serial monitor.

Send it to what? How do you KNOW that the XBee is sending anything? How do you know that anything is receiving it?

If you do not want to say how you have actually configured the XBees, please do not bother replying.

I have configured the Xbees using putty as shown in this video- Tutorial 09 for Arduino: XBee Wireless Communication - YouTube
I have one Xbee connected to an arduino with an empty code and sending data to the other xbee via XCTU console.
The other console is attached to an arduino with the code given by kamondelious above. So I can send and receive data using the serial monitor.
When I enter something in the serial montior and hit send, I can see that data in the XCTU console. But when I send something from the XCTU console to the other Xbee, nothing appears on the Serial monitor…

I have configured the Xbees using putty as shown in this video- Tutorial 09 for Arduino: XBee Wireless Communication - YouTube

That tells us the convoluted process that you used (X-CTU is far easier), but it does NOT tell us what values you assigned to what parameters.

Answer the questions. What VALUES have you assigned to PAN ID, MY, and DL on each XBee?

Pan ID for both is 1111
For First, ATMY=1000, ATDl=1001.
For Second ATMY=1001, ATDl=1000

As per your instructions, I have configured the Xbees again, using XCTU. Now the values are-
XBee-1
Channel : C
PAN ID : 1234
Destination Address Low : 3434
16-bit Source Address : 4343
XBee-2
Channel : C
PAN ID : 1234
Destination Address Low : 4343
16-bit Source Address : 3434

I am now writing a code for contolling a Servo motor using a potentiometer, via Xbee…
Here’s the code-

Sender-

//Define Pins
int potPin = 2;

void setup()
{
  //Create Serial Object (9600 Baud)
  Serial.begin(9600);
}

void loop()
{
  int val = map(analogRead(potPin), 0, 1023, 0, 180);
  Serial.println(val);
  delay(50);
  
}

Receiver Servo-

//Include Servo Library
#include <Servo.h>

//Define Pins
int servoPin = 9;

//Create Servo Object
Servo jeremysServo;

void setup()
{
 //Start Serial
 Serial.begin(9600);
  
  //Attaches the Servo to our object
  jeremysServo.attach(servoPin);
  
  delay(500);
}

void loop()
{  

  while( Serial.available() == 0);
  int data = Serial.read() -'0';

  int pos = map(data, 0, 9, 0, 180);
  pos = constrain(pos, 0, 180);

  //Turn the servo
  Serial.println(pos);
  jeremysServo.write(pos);
  while(Serial.available()>0) Serial.read(); 
  
  
}

The code is from Jeremy Blumms Blog.

After working with them for a few hours, I got the circuit right. But the Servo just Vibrates instead of rotating along with the pot. Anything I miss?

You are sending something like “120”, to move the servo to position 120.

Does the receiver code look anything like what it would need to to deal with that string of data?

Moving the servo to position 1, 2, 0, -38, and -35 when sending that string makes little sense to me.

If you really can’t figure out how to properly read, store, and use, when the end of the packet arrives, that data in a NULL terminated array of chars, then just use Serial.parseInt() to read the data.