Go Down

Topic: Problem with SoftwareSerial (Read 348 times) previous topic - next topic

Hatsuharu

Hello,

(sorry but I'm french...)
I have an Arduino Uno (R3) and I want to create a software serial port. I use the version 1.0.3 of the Arduino Software with this SoftwareSerial library exemple:
Code: [Select]
#include <SoftwareSerial.h>

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

void setup()  
{
 // Open serial communications and wait for port to open:
 Serial.begin(9600);
 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(9600);
 mySerial.println("Hello, world?");
}

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


And I have this in my terminal:

Quote
ðf~
~
~Ìþ`0Ìó3füþðf~
~
~Ìþ`0Ìó3füþ¼Õ::
              :ûÚtº
                   Vë¼Õ::
                         :ûÚtº
                              Vë¼Õ::
                                    :û?Útº
                                          Vë¼Õ::
                                                :ûÚtº
                                                     VëÀ¼Õ::
                                                            :ûÚtº
                                                                 Vëà¼Õ::
                                                                        :ûÚtº
                                                                             VëQS£O!O¡MCO!À&KH$Ò#0y=ààÀààÀÀÀÀàÀàÀÀÀàÀÀàÀÀàÀààxÕ::
                                                 :ûité
                                                      Vë«ÓÒR¤Útº*ë«ÓÒR¤Útº*ë«ÓÒR¤Útº*ëO!MMÞ5''!¿Q!åëþ«ÓÒR¤Útº*뤫ÓÒR
                                    ÚätéIÞ«ÃÒR
                                              ÚätéIÞ«ÓÒR
                                                        ÚåtéIÞ


I already tested with another baudrate and with different arduino but I still have this proble.
Also I used the AltSoftSerial library and it's the same display in the terminal

Do you have any idea ?

For more information on my project, I want to use the hardware serial with Xbee and the software serial with my computer to display information.

Thanks.

PaulS

#1
Feb 20, 2013, 05:52 pm Last Edit: Feb 20, 2013, 05:54 pm by PaulS Reason: 1
What is the baud rate setting of the Serial Monitor? It needs to match that of the Arduino.

What is connected to pins 10 and 11?

Quote
For more information on my project, I want to use the hardware serial with Xbee and the software serial with my computer to display information.

How are you connecting the software serial port to the PC? You'd be a lot better off using SoftwareSerial to talk to the XBee and the hardware serial port to talk to the PC.

Hatsuharu

I use an USB-serial adapter (Link) and I connect the TX pin of the adapter to the pin 10 (RX) of the arduino and RX pin to the pin 11 (TX).
In the Serial Monitor, the baud rate is set to 9600 baud .
For the Xbee, I use a Xbee Shield and I can't choose the pin that it uses...

PaulS

Quote
For the Xbee, I use a Xbee Shield and I can't choose the pin that it uses...

I can with the XBee shield I use (from Sparkfun).

It looks like you need a MAX232 chip between the Arduino and that device. That would explain the garbage in the Serial Monitor, because that device is not a TTL device.

Go Up