Pages: [1]   Go Down
Author Topic: Uno R3 Serial stuck to 9600  (Read 2023 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody,
i have this basic sketch running on my Arduino Uno R3:
Quote
void setup(){
  Serial.begin(9600);
  Serial.println("== Serial begin =="); 
}


void loop() {
  Serial.println(millis());
  delay(1000);
}

and i receive correctly data through the Serial Monitor. As soon as i change the baud rate for example to 14400 or 115200 i receive only garbled text like "žÓÿôøðÿðôüððò", even if the Serial Monitor baudrate is set accordingly to the sketch. I need to work at 115200 because i am building a tool to monitor FM frequencies with a GPS log, so i need the full speed not to miss bytes from the FM chip or the GPS unit.
I am using Arduino 1.0.1 on OSX Lion 10.7.5, i can't figure out what i'm doing wrong.

Thanks

andrea
Logged

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

I routinely use 115200 on my Uno R3 with a Mac, so I don't know what is happening to you. Did you upload the revised sketch?
Logged

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

Thanks Nick,
what do you mean with "revised sketch": the sketch with other baud rates in Serial.begin()? If it's so, yes, i did but that's when i have the problem. Today i tried also with an Arduino Mega 2560 and the problem persists, so it's probably a problem with the arduino interface more than hardware.
I don't know where to bang my head  smiley-confuse
Logged

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

so it's probably a problem with the arduino interface more than hardware.

What interface?
Logged

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

I mean the serial interface. I tried both the Uno and the Mega 2560 with a Win7 PC and the problem persists.
When i set the COM port baud rate to 115200 in the hardware preferences, and i broadcast from Arduino at 9600, everything works fine.
As soon as i move from that value in Serial.begin(), i.e. 14400 or 11520, i receive garbled text.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you must select the same baudrate in serial.begin (xxx )  and in the serial monitor
Logged

using Arduino Uno Rev 3

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

Thanks karlok, probably i was not clear enough: since the problem persisted, i tried using the highest rx baud rate to see if i was missing something.
So, here's my test sketch:
Quote
void setup(){
  Serial.begin(9600);
  Serial.println("== Serial begin =="); 
}

void loop() {
  Serial.println(millis());
  delay(1000);
}

I upload it in my Arduino UNO on Windows 7, COM6. I open the serial monitor at 9600baud, i receive:
Code:
== Serial begin ==
0
999
1999
3000
4000
5001
When i change Serial.begin(9600) to Serial.begin(115200), upload the sketch and i change the serial monitor to 115200baud, close and reopen it, i receive
Code:
Óýóðððúôûððððððà
even after resetting the board.
Thanks for your help.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

change the serial monitor to 115200baud, close and reopen it
This might be a stupid answer, but be sure to close the serial monitor then change the baud rate , that will automatically reboot your arduino.
Logged

using Arduino Uno Rev 3

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

Well, this happens even if upload the sketch, close completely the IDE and reopen it with the new baud rate.
I did a little progress anyway: using the 1.5beta IDE i receive correctly data at 115200 on Windows 7, i'll try again tonight on MacOSX with the new IDE.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just tested the following:
  • in the Sketch
    Quote
      Serial.begin(115200);
  • and in the Serial Monitor :
    9600 baud

This is how it should not be. These values have to be the same!

And the result was exactly what you posted
Code:
�Óüòúôðõøòúðáðàðððúàððäýààäàúåäàðôàðàððýàññáàäúåäÿààðôäôôðôðòýáååâàâåàäôòðôððððâçäñäòòóò

So, make sure the values are the same.

Change it in your sketch, upload it. Wait until upload finished.
Then open the serial monitor, some scrambled data will arrive, change the baud in the serial monitor, then it will purge/flush your arduino and you should see it in the right way. Otherwise it is something wrong with your PC / USB connection.

I did a little progress anyway: using the 1.5beta IDE i receive correctly data at 115200 on Windows 7, i'll try again tonight on MacOSX with the new IDE.
Ok, that is good. I don't work with Win7, so there might be other issues.
« Last Edit: October 25, 2012, 09:59:21 am by karlok » Logged

using Arduino Uno Rev 3

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

That's definitely what i don't do, thanks, i was close to post a screenshot but i thought that explaining it would be enough.
As i said, i'll try tonight with my Mac 'cause with Windows and IDE 1.5beta it works correctly.

thanks for your answers
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok. good luck smiley
Logged

using Arduino Uno Rev 3

BHZ, MG, Brazil
Offline Offline
Sr. Member
****
Karma: 10
Posts: 346
Android developer; Arduino enthusiast
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I mean the serial interface. I tried both the Uno and the Mega 2560 with a Win7 PC and the problem persists.
When i set the COM port baud rate to 115200 in the hardware preferences, and i broadcast from Arduino at 9600, everything works fine.
As soon as i move from that value in Serial.begin(), i.e. 14400 or 11520, i receive garbled text.

I've tested quite a few Arduino and clones (including homemade ones) with 115200 and they all work in Win7 64-bit.

Are you by chance trying to use the serial port of the Arduino UNO in 2 simultaneous connections (1 to the computer and another to the external device) ? If you are, that is not gonna work.

The best for debugging serial devices is the Arduino Mega, because it has 3 serial ports. Use Serial0 for the USB connection and Serial1 or Serial2 to the other device.
Logged

Learn to live: Live to learn.
Showing off my work: http://arduino.cc/forum/index.php/topic,126197.0.html

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

Thanks to everybody who helped, the solution is to use the new IDE 1.5beta on OSX too, everything works as expected.
Logged

Pages: [1]   Go Up
Jump to: