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