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
…
Serial.begin(your_preferred_baud_rate);
Serial.setRxBufferSize(1024);
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 = Serial.read();
content.concat(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
}
}
Enjoy!
Pete.