BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Migrating to new blynk

i m having problem migrating my program to be able to use in the new blynk app. ive tried adding the template id, device name, as well as the auth token and it seems to connect. but the problem is, it wont work like it used to in the old blynk app. the data wont be displayed on the lcd. what should i do? thanks for those wholl help

#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "TMPLyMhBYuUA"
#define BLYNK_DEVICE_NAME "Monitoring System"

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

WidgetLCD lcd(V2);

String data;
String I;
char auth[] = "Nt7IlQ1LKrJATx0Li43e7Im01kN_jsAr";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "realme C12";
char pass[] = "qwertyuiop";

BlynkTimer timer;
String myString; // complete message from arduino, which consists of sensors data
char rdata; // received charactors

// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent() {
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V1, millis() / 1000);

}

void setup() {
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sensorvalue1);

}

void loop() {
  if (Serial.available() == 0 ) {
    Blynk.run();
    timer.run(); // Initiates BlynkTimer
  }
  if (Serial.available() > 0 ) {
    rdata = Serial.read();
    myString = myString + rdata;
    Serial.print(rdata);

    if ( rdata == '\n') {
      I = getValue(myString, ',', 0);
      myString = "";
      lcd.print(0, 0, "Resistance:");
    }
  }
}

void sensorvalue1() {
  data = data + I;
  lcd.print(0, 0, "Resistance:");
  lcd.print(0, 1, data);
  data = "";
  delay(1000);
  lcd.clear();

}


String getValue(String data, char separator, int index) {
  int found = 0;
  int strIndex[] = { 0, -1 };
  int maxIndex = data.length() - 1;

  for (int i = 0; i <= maxIndex && found <= index; i++) {
    if (data.charAt(i) == separator || i == maxIndex) {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }

  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";

}

How have you defined your V2 datastream in the web console?

Pete.

After creating the template, there’s a bunch of virtual pins that are already there. Should i use them or use the datastream that i created instead?

Sorry im new to this thing

It doesn’t matter whether you use one of the pre-defined ones, or you define your own. The important thing is that it’s a String data type for use with the terminal, so in your screenshot it would need to be V4, V5 or V6.

Pete.

Thanks for the help. Much appreciated. I’ll try it now and see if it works. Thanks again

Its now working. Waahhhh. Thank you very much mr pete for the help

I think i celebrated too early. The program works on the mobile device now. But in the web server it’s not doing well. I used the label widget and when i run it, the widget only shows a blinking letter “p” that switches to “clr”. What do you think is the problem here? Please help

Difficult to say unless you share details of how you’ve configured the widget in the web console.

And post screenshots, not photos taken of your screen!

Pete.

here are the needed details

And is the widget in your app also connected to pin V7 ?

Pete.

Yes

Its working fine in the app but not in the web console

As I know, LCD widget is not supported in WEB interface. So, separate your data streams, i.e define to your label its own virtual pin and write appropriate data to it in your routine. Say, your LCD is tied to V7, and your label is at V8.

void sensorvalue1() {
  data = data + I;
  lcd.print(0, 0, "Resistance:");
  lcd.print(0, 1, data);

  Blynk.virtualWrite(V8, data); //set properties for V8 according to your data type
 
  data = "";
  delay(1000);
  lcd.clear();
}
1 Like

Thanks for the help. Gonna try it asap

It worked well now. Thank you sir pete and alegz for the help