SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By njkl44
#112501
So heres this video i made and i need help getting it to work. i have 2 arduinos and 2 xbees i havethem hooked up tx-tx and rx-rx. i have confugured them correctly and can talk to eachother. i just cant get it to send the code. The video explians the problem a little more. here is the code i am trying to send its really simple:
Send:
Code: Select all
//client
//setup
void setup()
{
  //init serial communication
  Serial.begin(9600);
}

//main
void loop()
{
  //send H
  Serial.print('H');

  //delay
  delay(1000);

  //send L
  Serial.print('L');

  //delay
  delay(1000);
}



Receive:
Code: Select all
//server

//led pin
const int led_pin = 13;

//incoming data stream
int stream;

//setup
void setup()
{
  //init serial communication
  Serial.begin(9600);

  //init led pin as output
  pinMode(led_pin, OUTPUT);
}

//main
void loop()
{
  //check incoming data
  if(Serial.available() > 0)
  {
    //read data
    stream = Serial.read();

    //check data
    boolean value = (stream == 'H' ? HIGH : LOW);

    //set led pin value
    digitalWrite(led_pin, value);
  }
}



Thank You

http://www.youtube.com/watch?v=NpGQHNQTYZU
By stevech
#112504
EDIT: On the wiring... TX to TX and RX to RX may be wrong. The TX of the AVR is its output. The TX of the XBee is its output. So you probably want TX to RX and RX to TX (null modem, they say).

I'm no Arduino library x-spurt, but a quick read of it says that Serial.read() returns an int, not a char.

Me, myself, I wouldn't try to use the
Code: Select all
stream == 'H' 
since stream is an int and 'H' is a char. Maybe the Arduino macros/library are forgiving. Rater
Code: Select all
(char)stream == 'H'
or some such.

In the hardware realm, the XBee has to be configured for transparent serial mode between XBee A and B. I think you have done that. The method to pair A and B differs if you are using a PAN coordinator or just disabling all that and telling A to use the 64 bit MAC address of B, and vice-versa. And of course the RF channel and PAN IDs.
By follower
#112523
Hi,

Please don't post your question in multiple forums on the site--it makes it harder for people to help you.
njkl44 wrote:So heres this video i made and i need help getting it to work.
Thanks for taking the time to make the video. From what you were saying it seems like you've also asked for assistance on another forum?
i have confugured them correctly and can talk to eachother.
I'm confused by what you say here and what you say on the video. Have you ever sent data successfully between the two XBees?

What are the boards you have the XBee connected to?

You mention something about connecting the 3V from the Arduino to the XBee--it won't be able to supply enough current.

From your code it looks like you're trying to have the serial connection shared between the serial monitor in the IDE and the the XBee module--is this the case?

Do you have TX and RX connected on both modules?

If you're using SparkFun supplied XBee boards then you could also contact tech support.

--Philip;
By stevech
#112542
I responded in another forum with some suggestions.
Among these were that the wiring needs to be TX to RX and RX to TX rather than TX to TX and RX to RX.
I wonder if these were helpful.