0

I have 2 nodes: one is a PC+arduino mega+xbee the other one is arduino micro+xbee. The 2 xbees are communicating fine, I have tested this with 2 separate arduinos. My problem is that when the second xbee hooked up to the micro it seems it does not try to send or receive data from the serial lines. It is connected to the first RX/TX pins in proper order (RX->Tx, Tx->Rx) on the micro.

This is obvious for me because if I start my program's setup section on the ardu with:

void setup() 

{
  Serial.begin(9600);
  while (!Serial);

The whole main program won't be running because the serial just never gets ready only if I plug my PC in.

When I try to send data from the PC->micro through xbee I see the Xbee receives it (led goes on the board) but nothing happens on the micro.

The micro right now is set to periodically send some debug data through the serial, I don't get that back either otherwise I would see the serial TX led on the micro blinking that it is sending the data. It only works when the PC is connected through USB.

Do I need some additional code for the xbee or is it require a hardware modification? I use a 5V-3V ttl converter as an extra hardware.

1
  • From the Arduino site: Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.
    – Len
    Commented Jul 21, 2016 at 12:28

2 Answers 2

1

It is probably because you are using the only Serial to communicate to both the devices - your PC and XBee. At any instant, you can communicate to only one device. So you might need an extra serial to get you go.

And, may be due to this conflict you can see TX led blinking. May be it's communicating with anyone of them, and the other one is receiving garbage.

0

From your description, it kind of hard to figure out which arduino doesn't react. Maybe a picture would help.

If it is the arduino that is connected to the PC then the problem is that the serial connection is already used to talk to te PC and therefore can't be used to talk to the XBee. you'll need to use one of the other serial connections on the atmega (serial1, 2 or 3)

Mind you that you don't need a microcontroller to connect an XBee to the PC. A simple UART to USB converter is enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.