2
\$\begingroup\$

I've been trying to send and receive data on Arduino using the Xbee pro 900HP but I can't get them to communicate. Does anybody have any good information or guides on how to achieve this?

At the moment I have two Arduino Nanos wired for serial communication to the Xbee pro modules.

the code for the transmitter:

int y = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(y);
  y++;
}

The code for the receiver:

int x = 0;
void setup() {
  Serial.begin(9600);
  delay(500);
  Serial.println("starting...");
}

void loop() {
  while(Serial.available() == 0);
  int data = Serial.read() - '0';
  
  Serial.print(x);
  Serial.print(" ");
  Serial.println(data);
  x++;
  Serial.flush();
}

please let me know about anything that could possibly be wrong im losing my mind over this and im assuming its something simple im overlooking.

\$\endgroup\$
11
  • \$\begingroup\$ The question is a little bit too broad to be solved easily. Take it in the chat maybe? And check this one out: forum.arduino.cc/t/xbee-pro-900hp-arduino-to-arduino-wireless/… \$\endgroup\$
    – Dejvid_no1
    Jan 29 at 22:42
  • 1
    \$\begingroup\$ I have updated the initial post to be more specific. Sorry for being to broad. \$\endgroup\$ Jan 29 at 22:51
  • \$\begingroup\$ I might be confused but your While statement with ";" seems strange. Try it with brackets "{ }" \$\endgroup\$
    – Dejvid_no1
    Jan 29 at 22:58
  • \$\begingroup\$ having the brackets and the ; doesnt seem to change anythign \$\endgroup\$ Jan 29 at 23:07
  • \$\begingroup\$ Try copying the example I posted. See if it works. You have some strange type casting and string modifications: int data = Serial.read() - '0' \$\endgroup\$
    – Dejvid_no1
    Jan 29 at 23:09

1 Answer 1

1
\$\begingroup\$

Your setup is a bit unclear. Is it two Arduinos talking to over an XBee link or is it something else? If you have two Arduinos talking to eachother try making your software to work with just the two devices talking via UART first, no XBee.

You mentioned Arduino Nano. This could be problematic since a Nano could be a 5V logic device and the XBee might bee a 3.3V logic device, you need to sort that out first. When that is good you should use the XTCU software that Digi has, to configure the modules. Setup the baudrates and set it to AT commands (coordinator?) before using them as UART bridges.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.