Serialmonitor / TeensyMoitor not working as expected

Status
Not open for further replies.

LoopMasta

Member
Serialmonitor / TeensyMonitor not working as expected

I am trying to debug a project with the Serialmonitor / Arduino IDE. But the Serialmonitor seems to be very unstable. To demonstrate my problem i wrote this little test.

Code:
int LED = 11;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
}

void loop() {
  Serial.println("HIGH");
  digitalWrite(LED, HIGH);
  delay(500);
  
  Serial.println("LOW");
  digitalWrite(LED, LOW);
  delay(500);
}

I expected to see something like this

Code:
HIGH LOW HIGH LOW HIGH LOW HIGH LOW HIGH LOW HIGH etc...

but i get this.

Code:
LOW LOW HHIGH LOW HIGH HIGH HIGH LOW HIGH LOW LOW HIGH

"HHIGH" is not a copy and paste error. Its the output i see in the TeensyMoitor. The LED output works as expected. :)

Is this a Teensy2 or a Arduino IDE or a coding Problem?

macOS Sierra, 10.12.2, Arduino IDE 1.6.13, Teensy2, USB-type:serial
 
Last edited:
It does not seem a coding problem, I tested your code on a Teensy 3.2 (don't have that obsolete 8bit AVR stuff here) with its Led pin 13, and with Serial.begin(57600); which seems to be a good default value for the Teensy 3.x Serial over USB, then waiting for the Serial to be initialized and up with while(!Serial); followed by a little delay(10); just to be sure that the communication might start afterwards. Could not reproduce your problem with that.
 
Hi Theremingenieur. I updated my code.

Code:
int LED = 11;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);

  while(!Serial);
  delay(10);
}

void loop() {
  Serial.println("HIGH");
  digitalWrite(LED, HIGH);
  delay(500);
  
  Serial.println("LOW");
  digitalWrite(LED, LOW);
  delay(500);
}

I added a short video to better explain my problem.
[video]http://alphakanal.de/static/videos/teensySerial.m4v[/video]
 
Any chance you can try this with a linux or windows PC ?
I remember the MAC had some problems with Serial over USB - this might be related ? It would be useful to know wether the PC is the problem, or Arduino
 
I'm running it here on a Teensy 2.0 connected to a Macbook Air running Sierra. Seems to work fine.

Here's what I'm seeing:

Screen Shot 2016-12-20 at 5.52.21 PM.jpg
 
Hi Paul. Its a genuine Teensy 2.0. I bought it from http://www.hitechstore.de one of your official distributors. I always buy the "original" stuff to support the creators. :) The Teensy 2.0 itself works great. My project is running just fine but debugging without a working serialmonitor is challenging. I'll test my other teensy boards today to check if its only this board.
 
I testet it with two other teensy 2.0 boards and one teensy 3.1. The monitor output looks the same. Strange ....

teensySerial.jpg

Next up is to run the test with linux.
 
Last edited:
I updated my Macbook Air to the latest 10.12.2 Sierra (which took a while...) Serial monitor still works fine, just like in the screenshot on #6.

I have no idea why it's not communicating reliably on your mac. :(
 
I'll retest soon on an 11 inch Mid-2012 Air... the same machine you're using.

I really want to figure out why this is happening!
 
The output of the monitor is not just "wrong". Its also not in sync with the blinking LED's. Sometimes it takes a few seconds until i get a Serial.println

Thanks Paul for you support.
 
Ok. Good to know. I tried to double check with a debian system (raspberian) but could not figure out what to do with the linux installer (TeensyduinoInstall.linuxarm) Every hint is welcome
 
With Linux, the Teensyduino is not downloaded with the Execute permission set. I have not done yet on RPI, but on ODroid (and x86...), I download the file, go to the file (with Firefox, I click and say open containing folder) and do right click on the file and do properties. Go to the permissions page and check the execute flag... Then when you double click on it, it should open up Teensyduino...

Also remember on Linux to setup the udev rules file
 
Ok. Thanks KurtE. It took me a while to get the arduino IDE with teensyduino running on debian. But it works and the serialMonitor works as expected.
Same teensy board same usb cable.

teensyDebian.jpeg

The problem seems to be my Mac. :-(
 
Last edited:
I remember now having had problems with a "stuttering" Serial over USB connection on my MacBook Pro some time ago. There was a Modem driver for a 3G USB modem installed (which I had connected only once for testing and then forgot about it). I solved the problem by going into the Network settings and uninstalling everything but the Ethernet, the Wireless WLAN and the FireWire connection, followed by a reboot.
 
Hi Theremingenieur. I removed all network services and booted the mac in save mode (e.g all kernel extensions off) but it didn't help. Same problem. The serial connection is unreliable. But when i use the terminal as a serial monitor it works great!!!!!!

Code:
ls /dev/cu.*
/dev/cu.AMPLIFi_30_34-Bluetooth  /dev/cu.Bluetooth-Incoming-Port  /dev/cu.usbmodem12341
screen /dev/cu.usbmodem12341 9600

teensyTerminal.jpg

So its not my mac hardware. Maybe it has something to do with my JAVA version?
 
Last edited:
When happens if you set the USB Type to RawHID and upload again?

In that mode, HID will be used to emulate serial. It's still all the Java stuff, but talking to a utility that uses HID. Might help to figure out if the problem is related to Java, or the serial stuff.
 
I have had this problem for a long time now too. Currently on Arduino 1.8.0, Teensyduino 1.34, OS X 10.11.6.

Edit: Changing to Raw HID also removes for me, but then I have to use Arduino Serial Monitor. Not the end of the world, but not a proper fix haha.

Some testing (as USB Serial):
I just checked Network settings as suggested by Theremingenieur and realized I had dozens of "not configured" devices including Teensy MIDI (which I can't remember actually using), at least 15 instances of "USB Serial <number 0-15+>", a Feather M0 (used one a few months ago), USB ACM (no idea what this is), and a few FTDIs (FT231/232.. USB UART, I use these every day), "USB __ Serial Converter" (no idea what this is).

When I delete them all and plug in a teensy it doesn't reappear.. nor when I upload a new sketch. maybe it will eventually again... but it hasn't caused the problem to go away.

Anyway my guess is that some service or config is seeing usbmodem.. and assumes the OS is just going to access it for network data, rather than just a serial port, or I wouldn't get so many mis-configured repeats showing up in my network settings, yeah? Nothing is taking control of the port since I can still open it in serial monitor or CoolTerm (both have the same behaviour). Beyond this I have no idea how to test that..

It does this with all my teensys (3.0, 3.1, 3.2, 3.5, 3.6). I'll have to try later with another device that comes up as a usbmodem in /dev/tty, but don't have anything on hand at the moment.

This is my test sketch for setting up the condition:
Code:
long counter;

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(counter);
  counter++;
  delay(200);
}

Some of the output (for example):

54
56
57
60
62
68
69
72
75
76
78
82
86
87
88
91

Strangely enough, I went to copy this output after it had been plugged in for a few minutes and it was working perfect. I had to unplug/replug 3 or 4 times before it started misbehaving again. Anyway hopefully this gives a little more hint as to what is happening?
 
p.s. I'm also getting a "Teensy Loader is unable to read your compiled sketch (r) This error should never happen." on the first upload after I switch USB Type. I think every time. If I just hit upload again it works until I change USB Type again. Not sure if this is related.
 
Status
Not open for further replies.
Back
Top