Pages: [1] 2   Go Down
Author Topic: SoftwareSerialExample doesn't work well.  (Read 1417 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

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

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?


Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Read this before posting a programming question

Your code? Both lots.
Logged


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

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.
http://arduino.cc/en/Tutorial/SoftwareSerialExample

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.


* CIMG1569.JPG (2223.92 KB, 2560x1920 - viewed 40 times.)

* lll.png (32.23 KB, 451x647 - viewed 33 times.)
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 116
Posts: 4316
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Quote
I used just "SoftwareSerialExample" code in Arduino Examples.

And how about posting said code?
Logged


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

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.


2.2 Mb attachment. How about sizing it down a bit?
I'm sorry! I'll size down it next time.

And how about posting said code?
It's just a code in Arduino Examples, but I put here.
Code:
/*
  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());
}
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


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

You have posted one sketch. What's running on the other device?
I have used the same code in both the Aruduinos.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

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

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.

So RX to TX, TX to RX, GND to Analog pin?
I connect GND to GND.


* IMAG0492.jpg (481.64 KB, 1632x976 - viewed 27 times.)

* 4800baud.png (24.92 KB, 403x182 - viewed 27 times.)

* 57600baud.png (25.33 KB, 404x183 - viewed 26 times.)
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 116
Posts: 4316
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: [1] 2   Go Up
Jump to: