Pages: [1]   Go Down
Author Topic: Xbee S2 and arduino mega  (Read 716 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, im using an arduino mega and i want to pass a value i get from an accelerometer to another arduino mega, what i did was to configure my xbee using x ctu, the first one i put the option of coordinatorAPI and the Pan ID 08 in the other xbee i put the option of End Device API and the same Pan ID 08 the both have the same baud rate in 9600 on the first one i used this code
Quote
void setup() //
{
  Serial.begin(baud_rate); //
  Serial3.begin(baud_rate);
}
...
void loop()
{
  cambio=0;
  TomaValores();
  cambio = CambioDir();
  if(cambio==1)
  {
    numero=ValorSale();
    Serial.print(numero);
    Serial.print("num q sale\n");
    EnviaValor(numero);
  }
...
void EnviaValor(int numero)
{
  Serial3.print(numero);
  Serial3.print(" ");
}
and finally in the other arduino i put this code
Quote
void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop()
{
  if(Serial1.available()>0)
 {
   a=Serial1.read();
   Serial.print(a);
   Serial.print("Recibi:");
   Serial.print("\n");
 }

am i doing something wrong??
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50366
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
am i doing something wrong??
Sorry, my crystal ball is at home. You'll need to tell us if you have a problem. If you do, you'll need to tell us what it is.

And, of course, you'll need to post code that actually compiles. I'm nearly certain that ... won't.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it dosent transmit and recives data, that code actually compiles, i just dont put all of it
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50366
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This tendency of yours to volunteer information needs some control. You are underwhelming us with data.

There are typically LEDs on XBee shields. Does yours have these LEDs? Do the one on the sender do anything when the sender tries to send data? Do the ones on the receiver ever do anything?

Just as a matter of idle curiosity, why are you using mesh networks modules to do point to point communication? Why are you not using the easier to use point to point (Series 1) models?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use series 2 to do point to point comunication, if I were you I'd set the Xbee modules on mode AT, this is a lot easier, you just have to set ID, copy the router's SH and SL so write on coordinator's DH and DL, do it again with the router. Everything that you write on Xbee RX will be transmited, and everything that is recived will be able on TX.
A easy tutotial is on http://tutorial.cytron.com.my/2012/03/08/xbee-series-2-point-to-point-communication/
Logged

Pages: [1]   Go Up
Jump to: