Serial println not displaying properly in terminal io window

There are several students in my class whose computer will not display the results from serial.println(“expression”); in the Io terminal window. I was informed that this is a known bug but I have not seen any discussion about it. For some students the serial.print command works fine, but for others there is a common error that it only will display a few characters (the first two) and that is it. Can someone please get back to me on this? This command is useful for troubleshooting in our labs.

1 Like

We’d need to know your platformio.ini and minimal code for reproduction. You do a Serial.begin() with a baud rate that matches the monitor_speed beforehand, right?

Yes. the code is simple. In main()

Serial.println(“Hello World”);

The output looking at the i/o terminal will display only the first 2 characters



At first I thought it might be just one computer’s configuration or a code issue. But there were several students that had the same problem. I was told that this is a known issue (serial print command has a known bug) Thanks

So again, which platformio.ini do you have? Which board? It may just be that either the board first starts sending messages at a different baud rate, thus messing up the decoding of the data, or that the serial monitor opens too late (which can be tested by adding a delay(1000); before the Serial.println)

1 Like

The typical platformio.ini file is shown below, Each student would have used the standard ini file that Visual Studio Code would have built during project definition. We are using the ATMega 2560 board. I’ll try adding in a delay the next time it occurs. Is the baud rate (9600) to high?

; PlatformIO Project Configuration File

platform = atmelavr
board = megaatmega2560
framework = arduino

Adding in the delay did not fix the error. What else do think they should try? All of the platformio.ini files are the same as above. We tried putting in a delay and that didnt work. I have 90 students in my class and some laptops work while others dont. Thanks for any suggestions.

Here is the simple code that you requested. Some laptops print the values on the serial terminal while others don’t.

#include <Arduino.h>
#include <avr/io.h>
#include “adc.h”

int main() {

unsigned int result = 0;
float voltage = 0;

// print out ADC value
// read in ADCL first then read ADCH
result = ADCL;
result += ((unsigned int) ADCH) << 8;
voltage = result * (4.72/1024.0);

return 0;

1 Like

Which OS are you using? If Linux, were udev rules installed?

Standard Windows operating system. I guess there may be some Mac laptops too, but so far the ones that I’ve seen that don’t work are on Windows 8 or 10

Does the text appear after closing the serial monitor in PlatformIO and opening the appropiate COM device on hterm.exe on 9600 baud (and “Newline at: CR+LF” setting) and pressing the reset button?

We’ve never used hterm.exe. Why would we need to do that? I thought the serial monitor in Platform IO is sufficient? I guess we’ll have to download additional software to install hterm.exe.

The link you provided for hterm.exe seems to be in German language. Is there an english version?

Okay I downloaded it and we’ll try that out. Thanks

Max only asked you to try hterm as it is better for analysing exactly what serial output you are getting…

For your first program, because it seems you are not using a standard Arduino setup or loop, but int main() arrangement, you are not allowing the hardware serial buffer to be flushed before the program terminates. You need to add Serial.flush() to ensure everything in the buffer is written before the program closes. Without it, it seems it only manages to write two bytes - He - before the processor is basically told to do nothing more.


#include <Arduino.h>

int main()
  Serial.println("Hello World");

  return 0;

If you are having problems with the other code, can you post the code for adc.h also?

We tried Serial.flush. That seems to be helpful, thanks. Here is the “adc.h” code.

#ifndef ADC_H
#define ADC_H

void initADC7();