Yet another garbled monitor output

Noob to arduino. Been in s/w development for far too many years.

elegoo uno r3 with the blink example. I did have a Adafruit 4485 Adafruit LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel/Gyro/Mag - Stemma QT Qwiic working. Started to get LowLatencyDatalogger working. Compiled ok. I then plug in the Seeed SD Card Shield and noticed the println's were messed up. Regressed by removing the shield. No change. Went back to blink example. Still garbled println. Tried different USB cables/ different usb ports on my Chromebook. Even tried: Serial.wirte/print/println still garbled output. Tried different baud rates. Still garbled output.

Serial.begin(9600);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
// Serial.write("hello, world");
// Serial.print("hello, world");
Serial.println("hello, world");

output looks like

helhello, lo, worlworld
d

I did get a timeout twice while downloading the sketch. Good R3 gone bad?

post the whole code
Arduino UNO - ok but is it CH340? do you have the driver? anything connected to it esp on pin 0 and 1?
the serial monitor needs to be open at 9600 bauds
Hello, do yourself a favour and please read How to get the best out of this forum. using code tags is a good thing...

Put Serial.flush() immediately after the Serial.println() and see if you get the complete output, it is likely something later in the code is causing the processor to reset.

Slight improvement:

hellhello, wo, worldorld

Don't post snippets (Snippets R Us!)

try this code

void setup() {
  Serial.begin(9600);
  Serial.println(); // in case of initial garbage
  Serial.println("1. Hello World");
  Serial.println("2. Hello World");
  Serial.println("3. Hello World");
}

void loop() {}

With nothing connected to the Arduino but the USB cable. what do you see in the Serial monitor, opened at 9600 bauds?

No @claude_j_greengrass
I'm not sure, but it shouldn't be written like this:
while(!serial) {}
?

RV mineirin

while (!Serial) delay(10); won't be triggered on a UNO. Serial is hardwired to return true.

When you upload a sketch, it takes about 150 milliseconds for the uploader to disconnect and the Serial Monitor to connect. In that time your sketch is running and, if it does Serial output, it puts characters into the output buffer. When Serial Monitor connects it causes the UNO to reset. Your sketch then starts again. The output before the reset often appears as garbled characters or duplicate output. To work around the problem, put a 200 millisecond delay between Serial.begin() and Serial output:

void setup()
{
  Serial.begin(9600);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens
  delay(200);
  // Serial.write("hello, world");
  // Serial.print("hello, world");
  Serial.println("hello, world");
}

void loop() {}

The UNO is a Elegoo UNO R3. Re: CH340 I just started with a couple of examples which worked ok. Never checked. Didn't see the need.
Nothing is connected to the R3 other than the usb cable. The monitor is/was always 9600 bauds. I just messed around on the off chance something might have changed.

Read the link the first time I posted to the forum. thx

Here is the blink code with my Serial.write/print/println add on

/*
Blink

Turns an LED on for one second, then off for one second, repeatedly.

Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
Arduino - Products

modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman

This example code is in the public domain.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// setup for monitor
Serial.begin(9600);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
// Serial.write("hello, world");
// Serial.print("hello, world");
Serial.println("hello, world");
Serial.flush()
}

// the loop function runs over and over again forever
void loop() {

delay(1000); //wait a bit for the serial port to be free)
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
// Serial.print("goodbye\n\n");
}

  1. Hel Hello Wlo Worldorld
    2
  2. He. Hello llo WorlWorld
    3d
  3. He. Hello llo WorlWorld
    d

The only thing connected to the R3 is the USB cable.

I put in a delay of 1000. It's better. Now I'm out of compile time and will have to change computers to upgrade my plan. Back soon (I hope).

1. 
1. HellHello Woo World
rld
2. 
2. HellHello Wo Worldorld
3.
3. Hel Hello Wlo Worldorld

hum that's pretty bad...

1. Hel Hello Wlo Worldorld
2
2. He. Hello llo WorlWorld
3d
3. He. Hello llo WorlWorld
d

which version of the IDE are you using? on what machine?


So why didn't you use code tags in your first post?


Editor (web) on a Samsung Chromebook Pro 91.0.4472.167 of ChromeOS

It may be the R3 has gone bad. I did have a Seeed SD shield attached this morning when I discovered the println problem. Striped that out, reverted to blink.ino and the problems persist. Twice I noticed a timeout while downloading the sketch. Not seen that problem again.

Any and all suggestions welcome at this stage.

Any & All -- Terminate Serial Monitor before attempting any Upload (if it's busy then the process can get hung-up).

I waited until the download completed: "flash complete" before starting the monitor. Results:


1. He
1. Hello llo WorlWorld
2d
2. He. Hello llo WorlWorld
3d
3. He. Hello llo WorlWorld
d

➜ get a real computer...

1 Like

I guess haven't had a "real" computer since 2004. I got hooked on Unix just after they separated I&D space (V7) about 1980. It's too late for me. I'm hopelessly lost in Linux land.

Stick with MS or Apple or whatever floats your boat.

I got hooked on Unix

I'm on a Mac, it's UNIX ™ under the hood and easy to use...

Actually it's BSD but that originally can from Unix.

I did resolve the Serial.println problem I was having. I switched from my Samsung CB Pro laptop to my Asus Chromebox desktop. It looks as if I have managed to zorch both my USB-C ports on my laptop. One was a bit iffy due to being used for all charging for the past few years. I must have zorched the other usb plugging and unpluging the R3.

Thanks to everyone for all the constructive feedback from everyone.

last I checked there The Register of UNIX® Certified Products