[UNO] - Basic serial commands not working.

Hi everyone,

I have two Arduino Unos that I can't seem to get talking to one another via serial. I uploaded the PhysicalPixel sketch to one, and another sketch which alternates the 'H' and 'L' characters (as documented in http://arduino.cc/en/Guide/ArduinoXbeeShield).

I've connected Pin 0 of one board to Pin 1 of the other, and vice-versa, and I cannot get the LED to cycle like the sketch says. One significant behavior i've noticed is that the TX LED on the sending Uno flashes every second when I have it powered via USB, but not when I have it powered externally (via a 9V battery or 12V wall wart). Additionally, if I have the Uno plugged in to external power and upload the sketch via USB, the Uno will flash the TX light every second (as the sketch says) until I plug the USB cable, then the TX light stops flashing.

What gives? Lasst week I had them talking to one another via XBee PROs, and now I can't seem to get them to talk simple serial.

Help!

Thanks!
-Matt

Do you have the grounds connected?

dxw00d:
Do you have the grounds connected?

I saw that in another thread, and did connect the grounds together, with no luck. Same result.

Should I try SoftwareSerial? is there a way to make SoftwareSerial work with the Xbees?

I saw that in another thread, and did connect the grounds together, with no luck. Same result.

Should I try SoftwareSerial?

If you can't send data via the hardware serial port, what makes you think you will be successful using two other pins?

is there a way to make SoftwareSerial work with the Xbees?

Yes, but what does that have to do with your problem of not being able to send data without the XBees?

PaulS:

I saw that in another thread, and did connect the grounds together, with no luck. Same result.

Should I try SoftwareSerial?

If you can't send data via the hardware serial port, what makes you think you will be successful using two other pins?

is there a way to make SoftwareSerial work with the Xbees?

Yes, but what does that have to do with your problem of not being able to send data without the XBees?

I feel like i'm missing something fundamental, and my trying SoftwareSerial, i'm starting from scratch in a different direction.

So I started from scratch, with this on one Arduino:

int LED = 13;
int incomingByte;

void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}

void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte == 'H') {
digitalWrite(LED, HIGH);
}
if (incomingByte == 'L') {
digitalWrite(LED, LOW);
}
}
}

And this on another:

int LED = 13;

void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}

void loop()
{
Serial.print('H');
digitalWrite(LED, HIGH);
delay(1000);
Serial.print('L');
digitalWrite(LED, LOW);
delay(1000);
}

And I can now get them to flash their LEDs! So I have progress. I attached the Xbees and powered them back on, but could not get the LEDs to flash in sync. I tried connecting grounds together with the Xbee shields attached and that didn't work. I removed the Xbees, re-attached the serial wires, and it started working again.

I'm going to re-program the Xbee modules again and see what happens.

I attached the Xbees and powered them back on, but could not get the LEDs to flash in sync.

I'm not surprised. Serial data transmission takes time, especially at 9600 baud. Sending data over the air takes time. Combining them and expecting 0 delay is unreasonable.

PaulS:

I attached the Xbees and powered them back on, but could not get the LEDs to flash in sync.

I'm not surprised. Serial data transmission takes time, especially at 9600 baud. Sending data over the air takes time. Combining them and expecting 0 delay is unreasonable.

I waited over a minute with no result. I had them talking previously, and they would start up and talk within a few seconds.

UPDATE: I tested both of my Xbees in the X-CTU app. One reads, the other does not. So I think I have a faulty Xbee module. Off to Sparkfun! Thanks everyone!

I waited over a minute with no result.

So you think if you wait long enough they get into sync automatically? Take another read of the post of PaulS. Serial communication means one bit AFTER the other is transferred. This needs time. First some time is needed for the serial communication from the first Arduino to the XBee, the XBee has to modulate these bits onto the radio signal, the receiving XBee has to receive all bits, demodulate them and send them to the second Arduino. So you have three serial lines each loosing some time, and every hop inbetween adds some delay because the data has to be processed, even if the algorithm is simple it needs some time. I'd always expect them to be out of sync and never to be in sync.

So I think I have a faulty Xbee module. Off to Sparkfun!

Or you bricked it. Most bricked XBees are recoverable. It's Google time.