Serial Monitor..

Status
Not open for further replies.

JohnPunnett

Active member
Hi All,

I am relatively new to Teensy 3.2 & making slow progress. Current problem is with displaying things on serial monitor - It seems a bit hit & miss - sometimes it works & other times I get nothing & I have no idea why. I have tried tons of different settings but most of time (say 9 out of 10) it fails to work. I am using

Arduino IDE 1.6.8
Teensy 3.2
I have verified COM Port setting (com5 in device Manager) - it appears & dissappears as I plug Teensy IN & Out
I upload program (which is basically reading data over I2C interface from accelerometer
Once program is uploaded I open Serial monitor with correct virtual com port set & like I say 9 times out of 10 NOTHING... :-(

It has worked though but no idea why.

I have also verified that prog works perfectly using same sensor & an UNO-R3 board..

I have tried various things suggested in posts to get working but still no joy.

Would really appreciate any help.

Many thanks, John
 
The Teensy uses native USB to talk to the PC so it doesn't matter what the COM port is as long as there is a connection.
One thing that might be getting you is that the communication is so fast that anything that is sent when your code first starts up may already have been sent before the Serial monitor has a chance to see it. If that's the case, you can make your code wait until the Serial object is instantiated like this:
Code:
  Serial.begin(9600); // The baud rate here doesn't matter
  while(!Serial); //wait for Serial to instantiate

Pete
 
Hi All,

I am relatively new to Teensy 3.2 & making slow progress. Current problem is with displaying things on serial monitor - It seems a bit hit & miss - sometimes it works & other times I get nothing & I have no idea why. I have tried tons of different settings but most of time (say 9 out of 10) it fails to work. I am using

Arduino IDE 1.6.8
Teensy 3.2
I have verified COM Port setting (com5 in device Manager) - it appears & dissappears as I plug Teensy IN & Out
I upload program (which is basically reading data over I2C interface from accelerometer
Once program is uploaded I open Serial monitor with correct virtual com port set & like I say 9 times out of 10 NOTHING... :-(

It has worked though but no idea why.

I have also verified that prog works perfectly using same sensor & an UNO-R3 board..

I have tried various things suggested in posts to get working but still no joy.

Would really appreciate any help.

Many thanks, John

I guess, you read about classic Teensy setup()
Code:
void setup()
{ while(!Serial || millis()<10000);
  Serial.println("Starting Setup");
  // setup other stuff
}
This allows you to wait up to 10 seconds for opening Serial terminal alter teensy has started.
by dropping the millis() test you can wait as long as you want before opening the terminal.

Teensy is sometimes too fast, so terminal programs may miss early text.

Edit: OK Pete was faster.
Note you do not need Serial.begin(9600); for USB Serial. I never use it
 
Please try TYQT - it works much more reliably and so much better.

You can have multiple Teensys online and watch them all efficiently - they automatically populate in the UI without picking a PORT that may move about.

The newest 0.8.0 version is not only reliable - but comes online a bit faster.

The is a 'Tool / Integrate to Arduino' that offers good help to uploading to one or more Teensys (replacing Teensy.exe loader) - and if more than one you pick which to upload to. And allowing it to be the loader allows coordination of dropping USB for programming without button press or other issues - and then come back online more quickly.

NOTE: Teensy gets to setup() in 400ms. If you rush some hardware - your i2c may be one - that isn't always ready when the Teensy is. So use the while(!Serial) as indicated in post #2 - no Serial.print() works before that completes - and perhaps don't do any i2c init until after that [ sometimes an added delay is needed ].

The WMXZ style is how I use it :: while(!Serial || millis()<10000);
Without that timeout clause provided by "millis()<10000" [ the time is your choice ] when run without an active USB connection the code will never continue - which may or may not be good - running from a USB battery pack for instance would stick on:: while(!Serial);
 
Status
Not open for further replies.
Back
Top