PZEM-004T with Blynk iot

Thanks again for your reply.
Currently I have an ESP8266 connected to a PZEM-004t with a CT, this monitors Voltage, Current etc.
All connected to the internet via wifi. I then have a Blynk app displaying values.

Code on the ESP8266

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
 
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <PZEM004Tv30.h>
 
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "pG1oTQwlWgKNwYOL0nzz1zlENe-qrp4A";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "VMKPSP60";
char pass[] = "********";
 
float voltage = 0;
float current = 0;
float power = 0;
float energy = 0;
float frequency = 0;
float pf = 0;
 
int On_Off = 0;
char flag = 0;
char estate_on = 0; 
char estate_off = 0;
 
/* Use software serial for the PZEM
 * Pin 11 Rx (Connects to the Tx pin on the PZEM)
 * Pin 12 Tx (Connects to the Rx pin on the PZEM)
*/
PZEM004Tv30 pzem(5, 4);
 
BLYNK_WRITE (V6){ //On and Off Button
 
  On_Off = param.asInt();
 
  if(On_Off){
 
    if(!estate_on){
      Serial.println("Sistem ON");     
      Blynk.notify("Sistem ON");
 
      estate_on = 1;
      estate_off = 0;
      flag = 1; 
    }
  }else{
 
    if(!estate_off){
      Serial.println("Sistem OFF");       
      Blynk.notify("Sistem OFF");
 
      estate_off = 1;
      estate_on = 0;
      flag = 0;
    }
  }
}
 

 
// This function get the values from PZEM004 via serial.
void Get_Values_From_PZEM(){
 
 voltage = pzem.voltage();
    if( !isnan(voltage) ){
        Serial.print("Voltage: "); Serial.print(voltage); Serial.println("V");
    } else {
        Serial.println("Error reading voltage");
    }
 
 current = pzem.current();
    if( !isnan(current) ){
        Serial.print("Current: "); Serial.print(current); Serial.println("A");
    } else {
        Serial.println("Error reading current");
    }
 
 power = pzem.power();
    if( !isnan(power) ){
        Serial.print("Power: "); Serial.print(power); Serial.println("W");
    } else {
        Serial.println("Error reading power");
    }
 
 energy = pzem.energy();
    if( !isnan(energy) ){
        Serial.print("Energy: "); Serial.print(energy,3); Serial.println("kWh");
    } else {
        Serial.println("Error reading energy");
    }
 
 frequency = pzem.frequency();
    if( !isnan(frequency) ){
        Serial.print("Frequency: "); Serial.print(frequency, 1); Serial.println("Hz");
    } else {
        Serial.println("Error reading frequency");
    }
 
 pf = pzem.pf();
    if( !isnan(pf) ){
        Serial.print("PF: "); Serial.println(pf);
    } else {
        Serial.println("Error reading power factor");
    }
 
    Serial.println();
    delay(1000);
}

 // This function sends the PZEM004 values to Virtual Pins.
// In the app, Widget's reading Hz should be set to PUSH. 
void Send_Values_To_Blynk(){
 
    // You can send any value at any time.
    // Please don't send more that 10 values per second.
    // Now, we are sending each time we call this function
    Blynk.virtualWrite(V0, voltage);
    Blynk.virtualWrite(V1, current);
    Blynk.virtualWrite(V2, power);
    Blynk.virtualWrite(V3, energy);
    Blynk.virtualWrite(V4, frequency);
    Blynk.virtualWrite(V5, pf);
 
}
 
void setup() {
 
  // Debug console
  Serial.begin(9600);
  
  //Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth, ssid, pass);
  
}
 
void loop() {
 
  Blynk.run();
 
  if(flag){
  
  Get_Values_From_PZEM();
  Send_Values_To_Blynk();
 
  }
  
}

I would like the same thing on the new Blynk iot system, but seems to be a lot more complicated that I thought.
As I said, bit of a numpty.
Kevin

Well, as I said earlier…

You posted a snippet of code which showed the variable types (all floats)…

and the variable pins that these are sent to…

It also appears that you have an on/off switch attached to pin V6, which is an integer data type.

You then asked a random question about a numeric input widget, which I still don’t understand, and posted a screenshot of a Blynk IoT web dashboard that you’ve built.

You haven’t provided any details about potential min/max values for your V0 to V5 data, or provided any information about the datastreams you’ve created.
You also don’t appear to have created a mobile dashboard in Blynk IoT to mimic your legacy mobile dashboard.

Pete.

Pete,
Firstly then, will the same code be accepted for the new Blynk iot system?

Secondly, from the Blynk.Console, Web Dashboard, Widget Box, I have chosen ‘Number Input’ dragged this over to the right to place on the Dashboard. In settings, gave a Title (Voltage), press ‘Create Datastream’, options of ‘Digital’, ‘Analogue’ or ‘Virtual Pin’. In Virtual Pin I have ‘Name’ (Voltage), ‘Alias’ (Voltage), ‘Pin’ (V0), ‘Data Type’ options of ‘Integer’ or ‘Double’, ‘Units’ (Volts) from pull down menu, ‘Min’ (0), ‘Max’ (260).

Repeat for other Virtual Pins. V1, V2, V3, V4, V5. The V6 set as Switch.

So, have I chosen the correct Widget?
The ‘Number Input’ does not have a ‘float’ as a data type.

Kevin

The number input widget is for you to input values, via the keyboard, in the console.

No.
Your existing mobile dashboard appears to use Labelled Value widgets.

I’m not clear why you’re trying to make life difficult for yourself in this way. Why aren’t you using the mobile dashboard to recreate your existing mobile dashboard?

A screenshot of the datastreams tab would be far more useful that’s this info.

Yes, once you’ve finished creating your template, then created a device based on that template and copied/pasted the three lines of firmware configuration code from the device info screen.

You will then delete this line…

and replace it with…
char auth[] = BLYNK_AUTH_TOKEN;

and re-compile the sketch, once you’ve installed the latest Blynk C++ library.

Pete.

Pete, again thanks for the info.
When I installed the new Blynk iot app it sort of led me to think I was to create in the Web Dashboard first and then on a mobile.
Tomorrow I’ll delete what I’ve got on the Web Dashboard and have a go at re-creating what I’m after on my mobile.
Cheers

Hello friend, I managed to migrate to the new blynk? I’m having the same problem and I’m needing to migrate to the new blynk, if you can help me, thanks.