Problem with communication with an Xbee Shield

Hello,
I recently bought these shields : http://www.seeedstudio.com/depot/XBee-Shield-V20-p-1375.html with these antennas : http://www.seeedstudio.com/depot/Xbee-Pro-IEEE-802154-24Ghz-63mW-250Kbps-RF-Module-w-UFL-Antenna-Connector-XBP24AUI001J-p-1967.html .

However, i can’t get these workings with my Arduino UNO. I just plugged the shields onto my arduino boards with the antennas and uploaded the following codes :
For the transmitter :
[
void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.print(‘H’);
delay(1000);
Serial.print(‘L’);
delay(1000);
}
]
And for the receiver :
[ 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);
}
}
}
]

I haven’t found anything in the Wiki so i really don’t know what to do !
Thanks for reading my message.

However, i can't get these workings with my Arduino UNO.

That's because this:

No configuration needed for out-of-the-box RF communications

is nonsense.

Thx for replying PaulS , do you have an idea on how to fix my problem please ?

I think you are a computer generated post.

It looks like you are not initializing software serial.

According to this site: http://www.seeedstudio.com/wiki/XBee_Shield_V2.0

you need to do step 3

  1. Use a jumper cap to connect XB_TX and Digital 4. Also, Use a jumper cap to connect XB_RX and Digital 5. Of course you can change the digital port as you like. But don't forget to change the port number in the definition of the demo code at the same time.

search for how to initialize software serial on forum or look at the demo code.

your Serial in your sketch would need to be changed to whatever you initialize such as XbeeSerial(8,4) //(RX/TX)

So I have to initialize like that :

#include <SoftwareSerial.h>
SoftwareSerial XBee(2, 3); // RX, TX

?

And change my Serial.print by Serial.write in my transmitter code ?

So I have to initialize like that :

#include <SoftwareSerial.h>
SoftwareSerial XBee(2, 3); // RX, TX

yes.

?

And change my Serial.print by Serial.write in my transmitter code ?

Both transmit code and receive code need to change all of the functions using the Serial identification to XBee;. I have used print and write with xbee. I dont know if one is better than the other. so it would be XBee.print() or XBee.read() or if XBee.available().

I think it is odd that your shield does not support digital ports 0 and 1. You wouldnt have to change your code if it did. you would just put jumpers connecting the rx and tx to the digital pins on the shield. In addition the shield is blocking the RX and TX pins? I have never used a shield, but I think one of the purposes of a shield is to bring all the pins up to the second pcb.

Edit 9:32AM PT
Nevermind i see pins 0 and 1 on the shield there just not available to the xbee.

Hmm thx for helping me but i don’t really understand what you mean, i have this shield (except that the black thing is between pin 2 and 3) :

What do you expect me to do with jumpers ?

Thanks.

For the transmitter, what’s wrong with this code (I want to send H and L, H will turn on a led and H will turn it off)

#include <SoftwareSerial.h>

SoftwareSerial XBee(2, 3); // RX, TX

void setup()
{
XBee.begin(9600);
Serial.begin(9600);
}
void loop()
{
XBee.write(‘H’);
delay(1000);
Xbee.write(‘L’);
delay(1000);
}

Double check that xbee rx is connected to pin 2 via the black thing. Same concept for tx.

For future modification You could try and probably jump the xbee pin with female connector and pins 0 and 1 with male.

I dont see error in your code it should work. Your xbees and shieldi i need to research

Your xbee pro modules require 215mA for transmit. Your shield doesn't give documentation on how it acquires the current. The shield says it can take any xbee module so I'm assuming it is wired to provide adequate current.

Your xbees need a U.FL antenna, However its my opinion that they will work very close range without one.

Check to see if the shields power led is light and when you run the transmit sketch on the uno check to see that the indicator light on the shield is green when the xbee is to be transmitting.

There is not much more information I can give Ill check this thread once more tomorrow or the following day.

Hi sb07,

I can't compile the transmitter sketch, i have the error 'Xbee was not declared in this scope' on the line where I wrote Xbee.write('L'), nothing happened for the line 'Xbee.write('H'), seems odd...

For the receiver i wrote this code :

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); pinMode(ledPin, OUTPUT); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if (incomingByte == 'H') { digitalWrite(ledPin, HIGH); } if (incomingByte == 'L') { digitalWrite(ledPin, LOW); } } }

its XBee... not Xbee...Case sensitive.

Lastly,

The receiver code needs to initialize software Serial unless you are using digital pins 0 and 1.

If you initialize software serial you need to change every word that is Serial to what ever you initialized software serial with.

Good Luck