(SOLVED) ESP8266 can't send data to App via WidgetTerminal or LCD

I created a simple set up with an ESP8266 (NodeMCU). I want to send strings to the App from this, via the WidgetTerminal. However it doens’t work, nothing is displayed in the App. If I run the App on two tables/phones (tested on iPad and Android) then I can see the text sent/received between the App. And the hardware is receiving what I send to it, but never send anything back.

Issues:
a) Can’t display any data in app from WidgetTerminal or WidgetLCD.
b) The chip icon on Android when running the app says the hardware isn’t connected. But I can receive data sent to the hardware, I output it to the serial terminal. Serial log shows that it connects to WiFi and connect to blynk cloud just fine.

Here’s the source:

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "XXXXXXXXXXXXXX";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YYYYYYYYYY";
char pass[] = "ZZZZZZZZZ";

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{
  // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
  if (String("Marco") == param.asStr()) {
    terminal.println("You said: 'Marco'") ;
    terminal.println("I said: 'Polo'") ;
  } else {

    // Send it back
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
  }

  // Ensure everything is sent
  terminal.flush();

  BLYNK_LOG("Yea we got data %s", param.asStr());
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("-------------"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));
  terminal.flush();
}

void loop()
{
  Blynk.run();
}

(EDIT): I added the source inline and I removed the LCD widget, I have the same issue with just the terminal.

Any suggestions?
/Hakan

Both Terminal and LCD are simple in operation, however I recommend you start with either the terminal sketch or the LCD sketch separately, then once you have gotten both to work properly work on merging them…

Also, it helps to post your code here in the forums… easier for us to quickly glance back and forth between questions, answers and code.

But please format it so it looks correct, thanks.

Is problem exactly with terminal or with all others widgets? It could wiring or bad Wi-Fi signal issue.

Thanks, I’ve posted the source inline and removed the LCD, it doesn’t work that way either.

I have only tested the terminal and LCD. Let me try something else that sends a command to the App. But isn’t it odd that I can send commands to the ESP? And why is it listed as offline in the Android app (iOS doesn’t say it’s offline). I’m very close to my WiFi access point and the wiring shouldn’t be an issue, it’s an integrated module (NodeMCU), only wire is USB.

If you are plugged into USB, then what does the IDE monitor show? Connecting or connected?

It says this:

[4397] Connecting to YYYYYYYYYYY
[35403] Connected to WiFi
[35403] IP: 192.168.240.173
[35403] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.6 on ESP8266

[35479] Connecting to blynk-cloud.com:8442
[35719] Ready (ping: 4ms).

As a test I created a new project, and got a new auth code. Then it worked, no other changes. Maybe my cloud-device got messed up, is it supported to run it on multiple App-devices (iPad and Android phone)?

So you are up and running and the terminal sketch is working as it should?

As for cross platform operations… yes, as long as you are using widgets the are fully supported on both Android and IOS, otherwise you will run into issues (typically on the IOS) where something may not work as expected.

As a dedicated Android user, I am not familiar with all the widgets that don’t work on IOS, but sometimes that detail is listed in the DOCs for the affected Widget.

Yes, it’s working in a new project/auth code.

I’m pretty sure the terminal-widget is supported on both, it’s available on both and it’s in a lot of the beginner tutorial (yea I know it’s not a guarantee, but it’s not like iOS is an obscure platform, hehe).

It would be nice to figure out what’s wrong with my other project. I know it’s not related, but is there a way to attach a device to multiple projects/copy the “device” auth code from project to project?

Not that I am aware of, since while you can change the auth code in the app, you can not choose the auth code, the server generates that automatically.

But what would you want to do that for anyhow… you can easily reload the appropriate sketch (with appropriate auth code) into your device for any given saved project, or am I misinterpreting?

I know, but it would be convenient to have several projects going to the same device (obviously not running at the same time) without having to load a new sketch. But I guess this is why, because I could potentially run it on two phones, so maybe there are good reasons behind it. I was just curious if it was something I had overlooked.

Oh, well that can already be done, at least I can on Android. I just use the same login on each phone and each phone then “sees” all my projects (which are actually stored on the server). Then I can control the device from multiple phones simultaneously… as I make changes on one phone (or, in the case of Android, tablet) they are reflected on the others.

Right, I did that too (between iOS and Android), but it was the same project (since the auth code is per project). But if you had two different projects running against the same hardware/auth code, maybe that could cause weird issues. Anyway, it’s not supported :wink:

Well, technically that works just fine on something like an RPi, as they are closer to a multi-tasking device then an Arduino or ESP, which is not. I currently have two different App projects, each running its own sketch (and own auth) on my RPi (one using WiringPi and the other using Nodejs), but both controlling the same LEDs and relays… and the limit of separate programs is really the processing power of the device

I run one on a phone and the other on the tablet, then fight with myself as to who has control… yes, I am easily amused :stuck_out_tongue_winking_eye:

Hehe cool! My RPis run Windows 10 IoT, but wanted to set up a cool project for 3rd graders in my son’s school for Science Day, and figured the Blynk project would be great for it, figured it was time to put it to use since I backed it on Kickstarter and haven’t tried it until now :slight_smile: