Pages: [1]   Go Down
Author Topic: Serial Monitor slow to kick in  (Read 344 times)
0 Members and 1 Guest are viewing this topic.
London
Offline Offline
Full Member
***
Karma: 0
Posts: 238
Arduino has it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I upload some code that is using Serial communication to the Arduino.

Than I turn on the Serial Monitor from the IDE. Than I send a character through Serial Monitor.

Now, the funny thing is, nothing happens. I send a character again, again and again. And, after doing that for a while, Arduino responds. Sometimes Arduino accepts character in the first attempt, sometimes I have to send it more than 10 times. After character was accepted, from then on, it accepts each caracter I send without the fuss.

Why are Arduino/Serial Monitor ignoring the characters sent at a begining?
Logged

Ontario
Offline Offline
God Member
*****
Karma: 20
Posts: 835
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect there is an error in the design of your sketch.
Logged

0
Offline Offline
God Member
*****
Karma: 1
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem here is defintely _not_ what you think it is :-)
Logged

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

Are you waiting for the code to finish uploading? That takes a good while on mine.
Do you have code running on the Arduino that is blocking whatever code you have receiving serial i/o, as in big fat DELAYS? Yes, 100 milliseconds counts as fat if it's in a loop.

Logged

Examples can be found in your IDE.

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 547
Posts: 45978
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget that opening the Serial Monitor resets the Arduino. You need to wait for the Arduino to reboot before you start hammering it with data. The simplest way to know it is ready is to add a Serial.print() statemet at the end of setup(). Don't bother hitting the Send key until you see the message you print.
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 238
Arduino has it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget that opening the Serial Monitor resets the Arduino. You need to wait for the Arduino to reboot before you start hammering it with data. The simplest way to know it is ready is to add a Serial.print() statemet at the end of setup(). Don't bother hitting the Send key until you see the message you print.

That is the smart cookie. I'll try that.

Just reasoning loudly. My code must be ok, because it works as expected once it receives its first character. Problem must be in some systematic delay, just as PaulS described.
Logged

0
Offline Offline
God Member
*****
Karma: 1
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I usually put a delay(1000) somewhere in setup() so I have the time to launch the serial monitor and catch the println(BANNER).
Logged

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

Opening the SM causes the Arduino to reboot? New one to me! I thought my buffer was catching all the text.

Logged

Examples can be found in your IDE.

0
Offline Offline
God Member
*****
Karma: 1
Posts: 596
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Opening the serial monitor is like pressing the reset button on the arduino board.
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 238
Arduino has it all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, that's what it is. Starting the Serial Monitor (SM) causes Arduino to reboot. And the delay was caused by that reboot.

I've just put something like: Serial.println("Arduino is ready"); into the setup () { ... }. If I wait for this to be printed back to SM, than I can start sending characters back to Ard. through SM.
Logged

Pages: [1]   Go Up
Jump to: