Xbee

Hey,
I have 2 xbee series 2.0's and want to make a message sending device through them.
Basically , i want to use it to send a message from the pit to a racing car ,and the reverse.It should be bi-directional.I am using the X-ctu software,and have configured them as master and slave respectively.
I was testing it with a push button,such that whenever the button is pressed the led lights up,on another arduino .After i press the button,the led does not light up,but is actually stored as a buffer,and when i switch the "master" arduino off,the led lights up.I have no clue whats going on,its acting like a buffer of some kind.
code on the master arduino:

int pushbutton = 2;

void setup() 
{
Serial.begin(9600); 
pinMode(2, INPUT);
Serial.print("start ");

}
void loop()
{
  digitalRead(pushbutton)
  if(digitalRead(pushbutton) == HIGH);
  {
    Serial.print("D");
  }
}

and code on slave is:

int led = 3;


void setup()
{
  Serial.begin(9600);
  pinMode(3,OUTPUT);
  Serial.print("start on slave");
}
void loop()
{
  
if (Serial.available() > 0);
{
  if (Serial.read() == "D");
  {
    digitalWrite(3,HIGH);
  }
else
{
  digitalWrite(3,LOW);
}
}

sorry for the long post.

Neither of your sketches compile for me...

sorry,semicolon error
master:

int pushbutton = 2;

void setup() 
{
Serial.begin(9600); 
pinMode(2, INPUT);
Serial.print("start ");

}
void loop()
{
  digitalRead(pushbutton);
  if(digitalRead(pushbutton) == HIGH)
  {
    Serial.print("D");
  }
}

slave:

int led = 3;


void setup()
{
  Serial.begin(9600);
  pinMode(3,OUTPUT);
  Serial.print("start on slave");
}
void loop()
{
  
if (Serial.available() > 0)
{
  if (Serial.read() == "D")
  {
    digitalWrite(3,HIGH);
  }
else
{
  digitalWrite(3,LOW);
}
}
}

And in the second sketch,

  if (Serial.read() == "D")

should be

  if (Serial.read() == 'D')

??

yes.sorry again.need to slow down. :cold_sweat:

Regarding the XBees, which has what firmware?

Regarding the master sketch, I'd debounce the button. The button will be held down for some amount of time, maybe 50-100 milliseconds. In this time, the loop() function will execute several times at least, and send a string of Ds. That's messy at best. Better if we had one D per button press.

Regarding the slave sketch, it will never turn the LED off. The else will never be executed since there is nothing but Ds sent.

Still, if all is configured correctly, I would expect the following behavior. The first time the button is pushed on the master, the slave LED should illuminate and stay on. Further button presses will have no visible effect.

jay2012:
yes.sorry again.need to slow down. :cold_sweat:

Copy and paste is usually both fast and accurate...

firmware: ZNET 2.5 CORDINATOR AT version 1047...on both the xbee's.
the led is not glowing.it glows like 7-8 times , in about 2 sec and then stops.
I get your point,thats why the serial monitor is actually showing D's continuously but there is also an "start on slave" command,which should be printed on the serial monitor as well..its not happening.

and i'd copy paste if i had the code written before.:smiley:

Every XBee network needs one and only one Coordinator. Configure the other as a Router. Don't think you want ZNET firmware. The current XBee ZB (S2) firmware is 2xA7, if it doesn't show up in X-CTU, click "Download new versions" on the Modem Configuration tab or if that doesn't work for some reason, get it here. Actually older firmware should work fine, so if you have 2xA0, 2x8C, 2x70 or 2x64, any of those should be fine.

Load the Router AT firmware (22A7) on the XBee connected to the master, and the Coordinator AT firmware (20A7) on the XBee connected to the slave. That should get you going, but it is only one way, for more details including two-way comm, see my blog post here.

Oh, and how are the XBees connected to the Arduinos? Shields? Adapter boards?

jay2012:
and i'd copy paste if i had the code written before.:smiley:

I'm confused. How could the code have not been written? Were you making the symptoms up, the buffer business and all?

int pushbutton = 2;

void setup() 
{
Serial.begin(9600); 
pinMode(2, INPUT);

Give the pin a name, but don't use the name. Why not?

  digitalRead(pushbutton);

Why? The digitalRead function returns a value and has no side effects. If you don't want the value, why make the call.

well,i didnt make it up...we are a team of 2,and i wrote the code on my team-mates arduino, not mine, and tested it there,so i knew what happened,and i coudnt reply yesterday because i did not have the zigbees with me.,and coudnt call my team mate up at 5 in the morning. :stuck_out_tongue:

ok,so here is the deal now.
I made a mistake in the above posts,we do not have a xbee series 2, we have one called the xbee pro xsc ufl..now according to the internet , they have stopped manufacturing it .But we did configure them as a master and slave, now comes the problem, in x-ctu, no function set is actually working for it,it always fails,basically we are trying to use the API mode ,can you please explain me how to do it,i am really clue - less about it.

paulS,
1.Why yes?.does it really matter what i use.?

2.Only when the pushbutton is pressed,and the circuit is completed and there is a HIGH i want D to be printed. how else would i do that?.

jay2012:
well,i didnt make it up...we are a team of 2,and i wrote the code on my team-mates arduino, not mine, and tested it there,so i knew what happened,and i coudnt reply yesterday because i did not have the zigbees with me.,and coudnt call my team mate up at 5 in the morning. :stuck_out_tongue:

Well, that's complicated! :smiley:

ok,so here is the deal now.
I made a mistake in the above posts,we do not have a xbee series 2, we have one called the xbee pro xsc ufl..now according to the internet , they have stopped manufacturing it .But we did configure them as a master and slave, now comes the problem, in x-ctu, no function set is actually working for it,it always fails,basically we are trying to use the API mode ,can you please explain me how to do it,i am really clue - less about it.

What is the part number on the bottom of the XBees? ufl would be the antenna connector. I don't recognize "xsc". XBee Pro can be either S1 (802.15.4) or S2 (ZB). So the first step here is to be certain of the hardware we are dealing with.

jay2012:
1.Why yes?.does it really matter what i use.?

Because you're asking for help. If you're going to force people to go through pointless lines of code, don't expect a great deal of help. This advice also helps prevent further issues.

2.Only when the pushbutton is pressed,and the circuit is completed and there is a HIGH i want D to be printed. how else would i do that?.

Remove that one line of code and I guarantee the functionality of the program will not change.

Jack,
here is the product,

ok,this is a special product by Digi, and they do not make this anymore.

arrch,
ill do it later,let me get the answer to my post first.

jay2012:
Jack,
here is the product,
XBee Pro 900 XSC RPSMA - WRL-09087 - SparkFun Electronics

ok,this is a special product by Digi, and they do not make this anymore.

Actually that is an S3B part, and while that particular part number (XBP09-XCSIT-009) doesn't appear to be current (I don't find it on Digi's web sire), I think these are equivalent.

You say you're trying to use API mode, that could be an issue, according to the product manual, this series does AT mode only. There is a binary command mode, but it appears limited to reading and writing module parameters, not sending or receiving the actual live data. Not sure what doc you may be following to do the API interface, but whatever it is, I think that it is inappropriate for this particular XBee series.

I don't recall seeing any discussion on this forum related to S3 modules and I haven't worked with them at all, but as always, GIYF.

thank you.ill look into it