BLYNK app cannot find my device

ESP32S with pzem004tv30 

cant seem to find my device on the blynk app, 
Maybe i am missing something?
cannot figure it out. Thanks for the help in advance, I am a beginner practicing home automation. 

#define BLYNK_TEMPLATE_ID "*********"
#define BLYNK_DEVICE_NAME "power monitor"
#define BLYNK_PRINT Serial
#include <PZEM004Tv30.h>
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "********";
char ssid[] = "*********";
char pass[] = "*********";

#if defined(ESP32)
PZEM004Tv30 pzem(Serial2, 16, 17);
#else
PZEM004Tv30 pzem(Serial2);
#endif
int show;

#define BLYNK_AUTH_TOKEN 
BlynkTimer timer;
LiquidCrystal_PCF8574 lcd(0x27);
unsigned long lastMillis = 0;
void setup() {{
    Serial.begin(115200);
    Blynk.begin(auth, ssid, pass, "blynk.cloud", 8080);
    timer.setInterval(1000L, sensorDataSend);
    
    // Uncomment in order to reset the internal energy counter
     //pzem.resetEnergy();
}{
  int error;

  Serial.begin(115200);
  Serial.println("LCD...");


  Wire.begin();
  Wire.beginTransmission(0x27); //Your LCD Address
  error = Wire.endTransmission();
  Serial.print("Error: ");
  Serial.print(error);

  if (error == 0) {
    Serial.println(": LCD found.");

  } else {
    Serial.println(": LCD not found.");
  } // if

  lcd.begin(16, 2); // initialize the lcd
  show = 0;
}}
void sensorDataSend()
{
     float voltage = pzem.voltage();
    float current = pzem.current();
    float power = pzem.power();
    float energy = pzem.energy();
    float frequency = pzem.frequency();
    float pf = pzem.pf();
       // reading sensor from analog pin
  Blynk.virtualWrite(V0, voltage );
  Blynk.virtualWrite(V1, current );
  Blynk.virtualWrite(V2, power );
  Blynk.virtualWrite(V3, energy );
  Blynk.virtualWrite(V4, frequency );
  Blynk.virtualWrite(V5, pf );// sending sensor value to Blynk app
}
void loop() {
    Blynk.run();
    timer.run();
    Serial.print("Custom Address:");
    Serial.println(pzem.readAddress(), HEX);

    // Read the data from the sensor
    float voltage = pzem.voltage();
    float current = pzem.current();
    float power = pzem.power();
    float energy = pzem.energy();
    float frequency = pzem.frequency();
    float pf = pzem.pf();

    // Check if the data is valid
    if(isnan(voltage)){
        Serial.println("Error reading voltage");
    } else if (isnan(current)) {
        Serial.println("Error reading current");
    } else if (isnan(power)) {
        Serial.println("Error reading power");
    } else if (isnan(energy)) {
        Serial.println("Error reading energy");
    } else if (isnan(frequency)) {
        Serial.println("Error reading frequency");
    } else if (isnan(pf)) {
        Serial.println("Error reading power factor");
    } else {

        // Print the values to the Serial console
        Serial.print("Voltage: ");      Serial.print(voltage);      Serial.println("V");
        Serial.print("Current: ");      Serial.print(current);      Serial.println("A");
        Serial.print("Power: ");        Serial.print(power);        Serial.println("W");
        Serial.print("Energy: ");       Serial.print(energy,3);     Serial.println("kWh");
        Serial.print("Frequency: ");    Serial.print(frequency, 1); Serial.println("Hz");
        Serial.print("PF: ");           Serial.println(pf);

     if (show == 0) {
    lcd.setBacklight(255);
    lcd.home(); lcd.clear();
    lcd.print("Balbes, M.L.");
    lcd.setCursor(0,1);    lcd.print("Racines, J.H.");
    delay(1000);

    lcd.setBacklight(0);
    delay(400);
    lcd.setBacklight(255);

  } else if (show == 1) {
    lcd.clear();    
    lcd.setCursor(0, 0);
    lcd.print("Voltage:");      lcd.print(voltage);      lcd.print(" V"); 
    lcd.setCursor(0, 1);
    lcd.print("Current:");      lcd.print(current);      lcd.print(" A");  

  } else if (show == 2) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Power: ");        lcd.print(power);        lcd.print(" W");
    lcd.setCursor(0, 1);
    lcd.print("Energy:");       lcd.print(energy,3);     lcd.print(" kWh");
  

  } else if (show == 3) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Freq.:");       lcd.print(frequency, 1);   lcd.print(" Hz");
    lcd.setCursor(0, 1);
    lcd.print("PF:");           lcd.print(pf);          
  }

  delay(1500);
  show = (show + 1) % 4;
}
 

    Serial.println();
    delay(1200);
}

First of all, you should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

What exactly does this mean?

What steps have you taken?

Pete.

The mobile blynk app, cannot seem to find my device. First I tried to regroup the timers and added delay to prevent blynk from disconnecting me to the cloud. I also tried using example sketches, and it works, thats why i pinpointed the problem to be in the code, which i cannot find where. Please enlighten me. Thank you very much

Don’t focus 9n the code.

You created a template. Was this in the app or web console?
You created a device from that template. Was this in the app or the web console?

Can you see your template in the web console?
Can you see your device in the web console?

Explain this stuff in detail.

Pete.

The template is both in the app and the web console, I tried connecting it as a device but it shows “device is offline”, for both. I also made sure that the templateID and DeviceNAME is at the very top.

are you using the latest version of blynk library which is 1.1.0 ?

Tried grouping the timers to make it as neat as possible. Yes the blynk library is up to date v1.1.0

[UPDATE] Just found out that the authentication changes when you create a device from template, I was using the same one when I was debugging. Now I can finally connect and see my device through the Blynk app and web console (device is online). The problem I am encountering now is not being able to receive data from my sensors. I know it works, because it prints out in my LCD and serial monitor, just not in Blynk.

  • Thank you John93 and PeteKnight for your helpful inputs

Maybe this video will help, if you want to connect your ESP32 with Blynk mobile app and over the wifi. It helped me to connect my ESP32. Have a look from 9:23min on the video.

credit to techiesms.

I’d start by looking at the min/max values you have assigned to your datastreams.
If you send values outside of this min/max range they will be ignored.

Pete.

Yes sir, I did exactly what you said, now it displays values accurately. All displays are synchronous with each other. Thank you so much for the help.

1 Like