PZEM-004T with Blynk iot

Hi, has anyone created a templet for the new Blynk iot?
I currently have a PZEM-004T monitoring my electricity supply, this set up on the old Blynk app but as the old system will be switched off I need to transfer over to the new Blynk iot system.

Every project created in Blynk IoT requires a template to be created.
How you configure your datastreams within that template will depend on what you personally want to achieve - and Blynk IoT doesn’t currently have a template sharing facility anyway.

Where exactly are you encountering problems?


Hi Pete, and thank you for the speedy reply. I currently have a project running with the old Blynk and was hoping to have the same thing. I didn’t put this project together so not sure of the contents. It shows, Voltage, Current, Power, Frequency and Power factor. Also has graphs and can save data as a CSV file.
It’s a shame there is no import facility

Assuming that you have the source code that’s running on your device then it shouldn’t be to difficult to migrate.

I’d start by looking at which virtual pin numbers the widgets in your app are connected to, what data types they use (integer, float string) and what the minimum and maximum values you expect are.
You can then create a Blynk IoT template which uses the same virtual pin numbers and you’ll know which data types to select and which min/max values to use.

Changing your code to work with Blynk IoT shouldn’t be too difficult, and there is a good guide in the documentation.


Pete, thanks again for your reply and also thanks for the advice. I’ll check this out and see how I get on.

Hi again Pete. I’ve created a template, i.e. V0 voltage, V1 current etc. These where ‘float’, but in the template widget box a ‘number input’ data type only gives a choice of ‘integer’ or ‘double’.
Will the Arduino script also need changing?

I don’t really understand the question, but I would have expected that of you want to input a number then you’d want that to be an integer or float variable type.

Can you elaborate on your question?


Screenshot of the template

[Unformatted code removed by moderator]

Pete, I’ve sent a section of the Arduino script and a screenshot of the Blynk template.
So the original that is still working was using float whereas in the new Blynk I haven’t had that option.
Am I doing thing right?

Start by editing your earlier post and adding triple backticks at the beginning and end of your code snippet.
Triple backticks look like this:

Your web dashboard isn’t really relevant at this stage, it’s the datastreams you’ve created that are important. But, without information about the virtual pins used in your current mobile dashboard the information will make no sense.

Are you planning on using the web dashboard alone, or are you going to create a mobile dashboard that mimics your existing web dashboard?


[Unformatted code removed by moderator]

Morning Pete, I put this to one side yesterday.
I have sent the full Arduino script.
You said in your last post to put the three backticks in the script, what is the purpose of this?
And Yes, I intend to use the mobile app and will build that late. from what I gather in the new Blynk iot you build the Web Dashboard first and then the widgets used there appear for use in the Mobile Dashboard.

You didn’t take note of my request for you to edit your previous post and add triple backticks before and after your code snippet, so that unformatted code has been removed.

In addition, you’ve posted more code and not used triple backticks there either, so that code has also been removed.

If you want assistance from this forum then you need to follow the rules about code formatting.


Pete, I think I now understand. The triple backticks are not to become part of the code, but allow code to be posted on this forum. Is that right?

Correct. This is explained when you create a post on the forum.


[Unformatted code removed by moderator]

I gave you triple backticks to copy/paste, but you decided to use different characters instead, which doesn’t work.

Once again, triple backticks look like this:


Hello again Pete. I couldn’t reply earlier as I’m new the forum restricted the amount of replies that I could make.
Sorry I’m being a bit of a numpty with regards to this, I’ll try again and send a section of code that I talked about earlier in the post.

/* 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;

Hope this is not removed this time.

If you’d edited your previous posts instead of creating new ones then that wouldn’t have been an issue.

You’ve now posted a (correctly formatted) snippet of legacy code, but I’m unclear where this fits into the narrative and what advice you’d like regarding the code.