101 serial connection is flaky

I use Ubuntu 15.10.

I got my 101 a few days ago and was testing. I figured that, even after going through all these permission and updating dfu-util tips, the serial connection is very flaky. Whatever sketch for 101 I run (with while(!Serial); in place, and with correct baud between sketch and monitor), It goes through these phase.

  1. I start with 101 on /dev/ttyACM0 with serial monitor up, and a sketch that blinks and prints at the same time
  2. upload (by the way, have to press reset every time)
  3. after 5 second device disconnection, 101 appears on a different port (/dev/ttyACM1). serial monitor dies with error
  4. I re-fire serial monitor. nothing coming out even though it blinks
  5. close the serial monitor and re-upload
  6. re-open the serial monitor on /dev/ttyACM0. it occasionally works(1 out of 2 tries) spewing out "hello world", occasionally doesn't.
  7. if I reset or disconnect 101 and then try to do serial monitoring later, it doesn't work again. It shows empty serial log, even when blinking.

Another thing: with 101 loopback test does not apply (as far as I have experimented). 101 in reset mode cannot be found by Ubuntu.

In comparison, Mega I bought together is doing fine on serial problem I mentioned. I bought 101 since it is supposed to be the successor to Uno, but now I feel more like I bought something that is alpha testing and not even beta.

Is there any way to remedy/bypass/workaround that problem? Without serial print debugging is nigh impossible.

This is the code I used. Blinking LED when serial monitor is running, but no print strings, for the most of the time.

void setup() {
Serial.println("Starting Serial");

void loop() {
if(!Serial) {
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
Serial.println("Hello, world!");

Get rid of while(!serial) as you have a ; , nothing is done.

Serial begin only in setup.


Thanks for the input, but that is definitely not the problem here. The led blinks, so the loop is running correctly.

I put while(!Serial); in the loop which is a recommended line for 101 in the guide because I wanted to capture if the board recognizes serial plugged in and monitor is running. It blinks when I start serial monitor and stops blinking when I close serial monitor(bc of while(!Serial) line, and thanks to that I know that it at least recognizes serial connection). Once in a while it actually prints something if I connect and disconnect and upload and reupload it enough, and that's the baffling part. I haven't seen anyone complaining about this, so maybe the board is defective?

I'll add some more in case somebody thinks I'm such a know-it-all newbie. I work as a software engineer, and that line is a lock to prevent null pointer errors while Serial is initialized in a multithreaded environment (like RTOS-running Arduino 101). That line is even in the 101 official start guide. I read it from the top to bottom.

I can even tell you that the serial example bundled with IDE is wrong. I put while(!Serial); in two pairs just in case the example is right but it's needed only in front of each Serial.begin().

I know what code works and what doesn't unless it's a board-specific issue, and I'm asking that. When the same code runs correctly on Mega2560 printing to serial, while the same code (not only that one, but all the examples from example folder or online) occasionally prints when I try several times but doesn't for the most times.

After all that hair pulling I decided it might be that the board arrived broken. There's no way an officially released board generally has this problem and I don't hear any complain about that.

I’m totally baffled. I uploaded the same code 10 times in a row and it suddenly starts working. And when I unplug and replug it it stops working again. Must be unstable contact points. Changing cable didn’t help.