BLYNK_DEBUG print to terminal

Well, best I have come up with is that the terminal is getting invalid (non-UTF-8) characters… I found some complicated conversion coding… but my head just exploded :boom: so I will save the rest for when (if) I wake up :stuck_out_tongue:

2 Likes

Ended up being the power supply was causing the issue. Hooked up a different one and no connection issues.

1 Like

So while everyone sleeps, Im left to figure it out on my own.

Just testing a theory here since I only have 1 esp connected to my PC at home and its performing tasks ( so I cant test for another 7 hours).

In setup, call Serial.begin() before Blynk connection.
Then setup the SerialEvent() function as per example but dont act on the new lines /n (?)
Once connected, print the inputString to terminal and then just monitor terminal with SerialEvent() ??

How close am I? lol @Gunner @Costas

I was taking a page out of @Costas “dangle a hint then leave em drooling, whilst I go have a nap” playbook… seems to keep the mystic factor elevated :wink:

I actually didn’t change much in the posted example, except stating terminal instead of serial, and calling the void terminalDisplay() with a timer.

/// these two lines added to script initialization
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete


void serialEvent() 
{
  while (Serial1.available()) {
    // get the new byte:
    char inChar = (char)Serial1.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}


void terminalDisplay() // send buffer to terminal
{
// print the string when a newline arrives:
  if (stringComplete) {
    terminal.println(inputString);
    terminal.flush();
    // clear the string:
    inputString = "";
    stringComplete = false;
  }

Oh,. and adding the buffer after the Serial1.begin() - the 2nd serial port on my Mega.

  Serial1.begin(9600);  // Debug serial port
  inputString.reserve(50);

I still haven’t figured out the odd characters and messed up alignment… I need to move this test into it’s own project as mangling it into my main test bed is causing many much overloads :slight_smile:

@Jamin I am a little too foggy today, so I will leave it to you to drag a few more tid bits of coding knowledge from @Costas I should be back sometime later.

Ah, yes, I can see that being an issue… low/bad power will cause all sorts of communication issues, and only get worse over distance and links. Good catch! :+1: As one would not normally go down that path because of the red herring tossed in by the works here, but not there diagnosis.

Meanwhile it looks like we have hijacked this post on a quest for the Holy Grail of a Debug Terminal :blush: Feel free to chip in.

Ok all.

I had a thought that timing (e.g. BAUD rate and other communication corruption) might be more of an issue then non-UTF-8, as far as all the diamond coated question marks are concerned, and after fiddling around with different rates, I think that is in fact the case.

Unfortunately I just can not get any improvement past this stage (terminal on the app and the approximately same info on termite). I also feel part of my problem is that I am also using USB to link to the server.

BTW, the slider and LEDs are to allow me to force flood errors, so I can see something besides the top half of “Blynk” in ASCII art :slight_smile:

So unless someone else drops another breadcrumb ;)… I am tapped out of intuitive ideas.

My code, such as it is:

#define BLYNK_PRINT Serial1 // Set to 2nd serial port
#include <BlynkSimpleStream.h>
#include <SimpleTimer.h>

char auth[] = "ded729afxxxxxxx768afe46a";  // Blynk App Authorization Code - Sorry Jamin... no tricks from you today ;)

SimpleTimer timerTERMINAL;  // Setup timer for terminal

WidgetTerminal terminal(V0);
WidgetLED led1(V2);
WidgetLED led2(V3);
WidgetLED led3(V4);
WidgetLED led4(V5);
WidgetLED led5(V6);
WidgetLED led6(V7);
WidgetLED led7(V8);
WidgetLED led8(V9);

String inputString = "";  // A string to hold incoming data.
boolean stringComplete = false;  // Whether the string is complete.



void setup()
{
  Serial.begin(19200);  // To server (via USB Link - batch file on PC).
  Serial1.begin(57600);  // For BLYNK_PRINT.
  Blynk.begin(Serial, auth);  // Connect to Blynk - Local Server.
  inputString.reserve(200);  // String buffer - experiment with differing sizes.
  timerTERMINAL.setInterval(1000L, terminalDisplay);  // Terminal print timer.
}



void serialEvent() // Capture BLYNK_PRINT serial data into buffer.
{
  while (Serial1.available()) {
    // Get the new byte:
    char inChar = (char)Serial1.read();
    // Add it to the inputString:
    inputString += inChar;
    // If the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}



void terminalDisplay() // Send buffered BLYNK_PRINT serial data to terminal.
{
  // Print the string when a newline arrives:
  if (stringComplete) {
    terminal.println(inputString);
    //terminal.flush();

    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}



BLYNK_WRITE(V1) // Lots of virtual LEDs to help cause flood errors. Slider send on release OFF.
{
  int value = param.asInt();
  led1.setValue(value);
  led2.setValue(value);
  led3.setValue(value);
  led4.setValue(value);
  led5.setValue(value);
  led6.setValue(value);
  led7.setValue(value);
  led8.setValue(value);
}



void loop()
{
  Blynk.run();  // Run internal Blynk functionality.
  timerTERMINAL.run();  // Run Timer for terminal.
  terminal.flush();  // // Ensure everything is sent to terminal.
}
2 Likes

I can’t get this code working on an ESP-12F…

Nothing comes up in the terminal that I havn’t specified in the code.

I have it running on a MEGA 2560 with Serial1 as the 2nd hardware serial port. So you would have to adjust accordingly to your setup.

And it doesn’t really work anyhow :stuck_out_tongue: I am working on something a bit more elegant… with less LED’s :wink: But right now this is becoming an exercise in knowledge as I fail to see how practical it could be, since during a connection failure, all the important data would never get to the terminal anyhow.

Yeh I changed Serial1 to Serial etc… but still nothing showed up… and dont have a Mega to test myself.

I think its time for @Costas to come to the rescue :stuck_out_tongue:

Do you have any USB 2 TTL adaptors to hook up to your ESP?

No, none :expressionless:

You shouldn’t need one… Set your programming port as the BLYNK_PRINT, IDE Monitor and link to pass the data to the widget terminal.

Wait… you are using this?? Where do you plug anything in? You must have a full breakout board or something to go with this.

Or check with @Costas whether it is even worth trying… my code may be crap :stuck_out_tongue:

I can’t explain it… somewhere between getting the screenshots and pasting my code in this post… I was trying so many things, that I must have dropped a decimal or something… because I can’t get it (what is pasted above) to work either?

And thanks to a mishap here (i.e. I forgot to save and said yes to an update reboot), I lost my “working” copy. :unamused:

Arrggg

Got it mostly working but never posted my results… at least here :wink: so for finality, here it is:

#define BLYNK_PRINT Serial1

String inputString = "";
void serialEvent1() {  // Check for data on 2nd serial port
  while (Serial1.available()) {
    char inChar = (char)Serial1.read();
    inputString += inChar;
    if (inChar == '\n') {
    Blynk.virtualWrite (V1, inputString);
    inputString = "";
    }
  }
}
BLYNK_LOG("Gunner has Ser>Term too ;) ");  // Called every second via timer for RTC display

2 Likes

Lol. So huge LEDs :joy:

Ah… I hadn’t noticed… even with both apps being 2.8.3 the LED’s on my tablet are actually bigger in scale (but text is slightly smaller) than on my phone:

(Nexus 6 - 2,560 x 1,440)

(Samsung Note 8.0 - 1,280 x 800)

In fact they are almost “true” 10mm LED’s on the tablet :smiley: I like it!! :+1:

3 Likes

Are you are willing to reveal how you got the whole ASCII image to print on terminal? Pretty Please :smiley:
I am still getting only partial logo and lots of ??? in diamond symbols on my attempts… hoping you might have some secret you have yet to reveal?

Despite to the fact I didn’t post anything here (no time to play during last weeks…:sweat:), I’m interested in this feature!! Please @Costas!! :blush:

Two months later, but I finally got that darn Blynk logo to show properly on the terminal… one way or another… :wink:

2 Likes

@Gunner very nice, do you have the code?

P.S. very ugly clock :slight_smile: