BLYNK_PRINT Serial - Where does this magic happen?


BLYNK_PRINT Serial is very useful, I like to see the connection process. If connection fails it’s useful to see if its WiFi failed to connect, Blynk failed, timeout etc . . .

Of course it’s only available via serial monitor, not accessible once a project is deployed.

As a learning exercise I’d like to display this BLYNK_PRINT Serial information on a display attached to my device, then once connected, clear the display and run the project as normal.

So, question “Where does the BLYNK_PRINT Serial magic happen?” If It is being printed to Serial Monitor I should be able to print it to LCD/TFT display also . . .

Thoughts/help much appreciated.


Hey Bill, another challenge…

The external LCD/TFT wont work unless you have something in the middle that will convert the TTL serial data into something understandable by the monitor

The solution I like is to send the data to a Terminal widget in the app.
This requires you to put a jumper across the Rx and Tx pins of your MCU. If you’re un=sing a NodeMCU/Wemos D1 Mini then this prevents you flashing the code via a COM port, but you can still do OTA or pull the jumper off temporarily.
These are the steps to set this working…

Add this somewhere near the top of your code to declare the terminal widget (on pin V1 in this example), and a variable that we can use to disable this serial output if you get bored with it…

//Support for Blynk terminal
WidgetTerminal terminal(V1); //terminal reads from virtual pin specified, possibly not needed when using "Blynk.virtualWrite(Vx, content)"
bool terminal_output_enabled = true;

In void setup(), just after your serial.begin you need to increase the serial buffer size. You also need to add a timer that sends the serial data to the terminal widget (this assumnes youvbe already declared a BlynkTimer object called timer


timer.setInterval(1000L, Send_Serial);    // Timer calls function to send any serial data to terminal

add this function somewhere in your code…

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 =;
    if (content != "")
      Blynk.virtualWrite (terminal, content);
} //end of void Send_Serial

That’s it, other than an optional widget button to turn the terminal_output_enabled flag on or off and a BLYNLK_WRITE(vPin) callback to handle that.

I also added another widget button that clears the terminal output using a clr command like this…

// A function where pressing the app button "Clear terminal" will of course clear the terminal output
BLYNK_WRITE(V2)    // Momentary button to clear the terminal
  if (param.asInt())
    Blynk.virtualWrite(terminal, "clr");  // Clear the terminal content



Thnx Pete,

Bit confused though . . . I want to access the Serial Print data BEFORE Blynk is connected (as it’s establishing WiFi, ping, connection etc. Using widgets would only work AFTER Blynk connected?

I assume somewhere deep in a Blynk library there must be some Serial.print() statements?

If I can get to those I should be able to TFT.print() if I initialise the TFT early in setup (before Blynk) . . . and print the same data to the TFTF as is being printed in serial monitor?

I’m using MEGA, MCUFriend TFT and ESP01.


OK . . . I found all the BLYNK_PRINT outputs in BlynkDebug.h . . . in a simple world I would just #define BLYNK_TFT, modify the library with a bunch of mirrored BLYNK_PRINT/BLYNK_TFT statements . . .

This is not a simple world . . . I think I found a challenge . . .


Yes, but the serial data is stored in the print buffer and sent to the serial monitor once the Blynk connection occurs. Of course, if it can’t connect to Blynk then you never see that data :thinking:

You could use the same type of function - send the serial buffer to the TFT screen rather than sending it to the Blynk widget.


HI Pete,

This is the data I want to see/print to TFT . . .it is happening before/during Blynk connect

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[2354] Connecting to GoTigers!_2GEXT_EX6100
[5572] AT version: 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
[6680] Failed to enable MUX
[13770] +CIFSR:STAIP,""
[13778] Connected to WiFi
[24645] Ready (ping: 23ms).

If I see “Failed to connect WiFi” in the Serial Monitor (rather than Connected to WiFi shown here), I just hit the Mega reset button. It would be nice to see the same info whne not connected to Serial Monitor so that I know where the connection process has failed.

I’ll have a play with your functions, certainly much simpler than modifying the BlynkDebug.h library . . . I don’t understand the lower level programming enough to make any meaningful modifications to the libraries other than by intuitive cut/paste trial-and-error . . . and with the complexity of BlynkDebug.h it will be a big/long task.


Look here…


Thnx, will have a look over the weekend :wink:


Thnx @Gunner , perfect!


MCUFriend 3.5" 480x320 TFT LCD
Arduino Mega2560

Following your prompts, and after days and days of modifying the BlynkDebug.h without really knowing what I am doing, in the end it was quite simple. I moved the MCUFRIEND_kbv definition to the top of the sketch, defined BLYNK_PRINT tft . . . and it worked!

#include <SPI.h>              
#include <Adafruit_GFX.h>     
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define BLYNK_PRINT tft


Thnx everyone for your help!

PS: Better quality video showing the full connection process and end result.


Is this possible with ESP–01 and Mega combo setup or is this even possible with ESP8266 or ESP32 ?

Hi, yes, I did this with a Mega and ESP-01 and MCUFriend TFT Shield.

This TFT Shield requires 8-bit parallel data lines plus five more control lines, there are not enough pins available on ESP8266 for this display. I have not tried it on ESP32, it ‘should’ be possible, there are enough pins on the ESP32, however you would have to change the default pin assignment in the MCUFRiend_kbv.h library.

In theory this should be possible for any display as long as you have the proper display libraries, and can support the same print functions that BlynkDebug.h uses.


1 Like

Totally possible with most any MCU and display/library combo… My last posted attempt was with an ESP32 using a simple 5 GPIO VGA output (to an old VGA monitor) via Bitluni’s ESP32Lib library GitHub - bitluni/ESP32Lib

Obviously if the display library used the simular print functions as Blynk, then a simple #define BLYNK_PRINT target redirection works simpler, instead of all the convoluted character, by character rerouting for the weird and random displays that I tried :slight_smile:

1 Like

Great job…

Hmmm, now I am left wondering why I never tried this with my largeish 3.5" LCD display that I had for my Mega2560… doh… I guess by that time I was focusing on the ESP32.

1 Like