SoftwareSerialExample doesn't work well.

Hi, I tried to use "SoftwareSerialExample" in Example of Arduino IDE 1.0.3, but it didn't work well I used 2 Arduino UNO (R3). I connected one Arduino's pin 10 to TX of another Arduino, and pin11 to RX accroding to the example.

After pushing the reset buttons of the latter Arduino, I should see "Hello, world?" in the former's serial monitor. But, I got only unreadable characters. I fixed baud numbers, but it can't work well. Could you help me find a solution to this problem?

Did you connect the grounds, too? Show a picture! Show some code!

RX to TX and TX to RX and just as Paul says, GND to GND.
The minimum serial cable has long been 3 wires.

Also how long are your wires and what baud rate are you trying?

Read this before posting a programming question

Your code? Both lots.

Hi all!
I puts a picture of the 2 Arduinos, and a screenshot of the serial monitor.
I used just “SoftwareSerialExample” code in Arduino Examples.

Baud rate I used is 57600.

When I pushed the reset button of the Arduino connects a USB cable,
“Goodnight moon!” appears in the serial monitor.
When I pushed it of another Arduino,
the unreadable characters appears there.

From the example :

  • RX is digital pin 10 (connect to TX of other device)
  • TX is digital pin 11 (connect to RX of other device)

You seem to have RX of the left device connected to pin 11 of the right device (yellow wire) and TX of the left device connected to pin 10 of the right device (red wire)

  • CIMG1569.JPG (2223.92 KB, 2560x1920 - viewed 4 times.)

2.2 Mb attachment. How about sizing it down a bit?

I used just "SoftwareSerialExample" code in Arduino Examples.

And how about posting said code?

UKHeliBob:
From the example :
You seem to have RX of the left device connected to pin 11 of the right device (yellow wire) and TX of the left device connected to pin 10 of the right device (red wire)

I think the connection is not wrong.
When I exchange the cables, I can’t get anything from the Arduino which has no USB cable.

I’m sorry! I’ll size down it next time.

It’s just a code in Arduino Examples, but I put here.

/*
  Software serial multple serial test
 
 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 
 The circuit: 
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)
 
 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts, 
 so only the following can be used for RX: 
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
 
 Not all pins on the Leonardo support change interrupts, 
 so only the following can be used for RX: 
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
 
 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example
 
 This example code is in the public domain.
 
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

You have posted one sketch. What's running on the other device?

I have used the same code in both the Aruduinos.

tkawa: I have used the same code in both the Aruduinos.

You have connected the hardware serial of one UNO to the software serial of the other UNO. That sketch sets the hardware and software serial ports to different speeds, so your arrangement won't work.

You need to connect the software serial of one board to the software serial of the other, remembering to cross the Rx and Tx connections over. When you do that you should see "Goodnight moon!" from your local UNO, then "Hello, world?" sent from the other Arduino.

So RX to TX, TX to RX, GND to Analog pin?

PeterH:
You have connected the hardware serial of one UNO to the software serial of the other UNO. That sketch sets the hardware and software serial ports to different speeds, so your arrangement won’t work.

You need to connect the software serial of one board to the software serial of the other, remembering to cross the Rx and Tx connections over. When you do that you should see “Goodnight moon!” from your local UNO, then “Hello, world?” sent from the other Arduino.

I tried your connection. I put a picture and screenshots of the connection.
When I took the screenshots, I pushed the reset button of the left Arduino first, and it of the right second in the picture.
But, still it can’t work.

GoForSmoke:
So RX to TX, TX to RX, GND to Analog pin?

I connect GND to GND.

4800baud.png

57600baud.png

This thread is getting more complicated as time goes by.

From the comments at the top of the code posted

" Receives from the hardware serial, sends to software serial. Receives from software serial, sends to hardware serial."

So, hardware serial on one Arduino and software serial on the other. Not software serial on both.

Wiring looks fixed. 10 to 11, 11 to 10, GND to GND.

The hardware serial is running at 57600 baud so the fact the serial monitor shows rubbish at 4800 is expected. The lower screen shot at 57600 should work, from my understanding of the sketch and your wiring. It correctly shows the output from the local (right) Arduino when you reset it. I assume that the corrupted characters resulted from the reset of the remote (left) Arduino. That should be sending "Hello, world?" but you received something like "C*±±½± °½É± 'ýjRü".

That's not exactly the right number of characters but is roughly the right length, and the "±±" where "ll" should appear suggests that you're seeing a mangled version of the original text.

If you have another USB cable I'd suggest connecting both Arduinos to the PC and open a second instance of the serial monitor to see what you're getting from the left Arduino's hardware serial. It almost looks as if the two boards are running at different speeds or different serial encoding settings, although I don't see any reason why that would happen.

GoForSmoke: Wiring looks fixed. 10 to 11, 11 to 10, GND to GND.

That would be the wiring for soft serial to soft serial though.

That's what he should be doing between UNO's isn't it? Just needs to change the code a wee bit?

i'm new to arduino i can't figure out how to fix when i get the error like this

sketch_jan28b:0: error: 'SoftwareSerial' does not name a type sketch_jan28b:0: error: 'Wire.h' does not name a type sketch_jan28b:0: error: 'NewSoftwareSerial' does not name a type there is no 'NewSoftwareSerial' on the file there is no 'wire.h' on the file

i'm new to arduino

That's no excuse for not telling us which version of the IDE you are using or posting your code.

Try again.