Terminal BAUD rate

Hello,

I wanted to know if the terminal print is affected by the baud rate that we set in the setup() ?
I have a sketch where in there are lot of terminal.println along with Serial.println.

The problem is after the particular line of code has been executed the terminal window will not show the prints. But here in the serial monitor the messages are printed out at exact time…but in the terminal window there is a delay, later all the messages will be dumped at once. (creates a confusion)

Is it the BAUD rate causing the issue or having the serial prints at the same time ?
I tried changing the BAUD rate but did not work. Or is there any limit of lines to be send to terminal widget ?

The terminal widget doesn’t have a baud rate, but if you write too much data too often then you’ll flood the server with data. The limit is about 10 writes per second, and this includes strings of data sent to the terminal, Blynk writes and virtual writes, writes to LED widgets etc.

Pete.

I am sure its below 10 writes/sec… There are not virtual writes or any LED widget called during this terminal.print part of the code. Does serial.print affect the terminal widget ? I mean taking up more memory ?

I don’t think memory has anything to do with the issue you’re describing.

Pete.

1 Like

Where’s the code? My problem when I started was forgetting to put

terminal.flush();

at the end.

1 Like

Hello,

The code is too big, and also too clumsy :grimacing: i dont want you guys to laugh at me.

I did not find any article where i can understand what is flush ! Can you please tell me what is its functionality ?

Don’t hide your mistakes… you won’t learn if you do.

BTW I’m not a pro.

I haven’t found any docs on it but it seems to be the send command every loop after all the info is ready. Try it and let me know the results.

The process of terminal output is now much better. But it prints only half of the message.
If the message is "Hello Blynkers" it would print Hello Bly, and during the next terminal print with diff message it will print the remaining letters of the message and carry on . I am feeling the code is blocking Blynk from sending messages. There are no delay in the code.

I think @daveblynk is correct in saying you need to add to many places (where complete msg needed to be sent)

terminal.flush();

The purpose of flushing is to push all the remaining data out of buffer and force those data to be sent, so that you can see the complete, not broken messages.

That’s why you will see remaining letters of the previous message in next msg if you don’t use flush.
Try flush in many places and see the result.

Yes i have added terminal.flush(); at points where the pieces of messages are not printed.
And now it seems to be printing the whole message. Yet to add terminal.flush(); at many more places.

Thank you for pointing me in the right direction… :clap:

1 Like

The documentation for the terminal widget commands is here:

Also, @Madhukesh, maybe a more elegant way iis to have a single function that prints the data to both your serial monitor and to the Blynk terminal, then you pass the data that you want as a string, either as a global variable or as a parameter?

BTW, there is a way to echo everything from the serial monitor directly to the terminal widget. You have to put a jumper across the Tx and Rx pins of the MCU, which needs to be removed each time you re-flash the code (but not if you use OTA updating).
This code example uses a runtime variable to decide whether or not to output the serial data, so this could be disabled with a button widget. The code assumes that the terminal widget is on opin V1.
The function is called using a timer, set to 500ms in this example. This means that there will be
as small delay between the serial and terminal output. You could reduce this if you wish, but half a second seems to work well in practice.
The example assumes that you already have a BlynkTimer object set-up called timer, and that you have timer.run(); in your void loop.

bool terminal_output_enabled = true; // put this at the top of your code, with the other variable declarations

Serial.setRxBufferSize(1024); // Increase the serial buffer size // put this immediately after your serial.begin command in void setup

timer.setInterval(500L, Send_Serial);    // Put this in your void setup

void Send_Serial()
{
  // Sends serial data to Blynk as well as the serial monitor (handy for setups where the MCU isn't connected to serial because OTA is being used)
  // Note that a jumper is needed between Tx and Rx, which needs to be removed if doing a serial flash upload (but this is not necessary for OTA flash upload)

  if (terminal_output_enabled)
  {
    String content = "";
    char character;
    while (Serial.available())
    {
      character = Serial.read();
      content.concat(character);
    }
    if (content != "")
    {
      Blynk.virtualWrite (V1, content);
    }
  }
}

Pete.

1 Like

I am going to try this and update you on this.
But after placing termina.flush it seems to work fine.
BTW once the nodemcu is fixed inside a box there is no need of Serial.print anymore. I also commented out the serial prints but that did not make any diff as you said earlier…