Go Down

Topic: Change Power Level Xbee (series1) (Read 2 times) previous topic - next topic

PaulS

Quote
Do you guys nows what's wrong with the code?

That code should be in setup(), or a function that gets called only as needed, not in loop().

The code talks to the XBee, but doesn't listen to the XBee. Why not?

acintra


Quote
Do you guys nows what's wrong with the code?

That code should be in setup(), or a function that gets called only as needed, not in loop().

The code talks to the XBee, but doesn't listen to the XBee. Why not?


The code isn't listening to xbee because this is only a prototype code, I'm using that just to learn how to use the AT commands in the source code. After I will do a complete code to my project
But thanks PaulS like always you helped me a lot.

PaulS

Quote
The code isn't listening to xbee because this is only a prototype code, I'm using that just to learn how to use the AT commands in the source code.

In the production version, you might be able to get away with not reading the reply. In the prototype/development phase it is crucial to read the reply, to make sure that it is what you think are getting.

acintra

Ok that's still not working...
This is the code that I'm using now:

Code: [Select]

void setup ()
{
  Serial.begin(9600);
 
  Serial.print("+++");
  delay(3000);
  if(Serial.read()=='OK'){
  Serial.println("ATPL");
  delay(1000);
  if(Serial.read()>=3){
  Serial.println("ATPL 2");
  delay(1000);
  Serial.println("ATPL");
  }
  }
}

void loop ()
{
 
}


But I'm still note receiving the "OK" from the command "+++", and not receiving too the return of ATPL.
I listened to the returns too like you said. I really don't now what to do to this works.

PaulS

Serial.read() returns one byte. That one byte is almost certainly not equal to the multibyte constant 'OK'.

Go Up