The blynk shows only live data

Hello,
I have a problem when I used blynk(the old version) last night. Before last night, at noon, I can measure every data and show it in every graph. But when I change the device to measure the data, it just like the blynk has stopped working, just like it didn’t accept any information (in the superchart)

P.S. I’m only Thai student, doing the project and running the code as given by teacher, so I don’t exactly know how to fix the code though and sorry for my bad English grammar at all.:sweat_smile:

P.S.2 here is the code and the photo of the blynk when measure the device in the other time period section. ( The live section can work normally)
Thank you for your help.:sparkling_heart::sparkles:

#define  BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Time.h>
#include <PZEM004Tv30.h>
#include <SoftwareSerial.h>
#include "DHT.h"
#define DHTPIN D2
#define DHTTYPE DHT22
#if defined(ESP32)
    #error "Software Serial is not supported on the ESP32"
#endif
#if !defined(PZEM_RX_PIN) && !defined(PZEM_TX_PIN)
#define PZEM_RX_PIN D3
#define PZEM_TX_PIN D4
#endif


SoftwareSerial pzemSWSerial(PZEM_RX_PIN, PZEM_TX_PIN);
PZEM004Tv30 pzem(pzemSWSerial);

DHT dht(DHTPIN, DHTTYPE);
WiFiClient client;
WiFiServer server(80);

int    timezone    = 7 * 3600;        // ตั้งค่า timezone
int    dst         = 0;               // ตั้งค่า daylight saving time 
int    SignalStrength;
String DAY;
String DATE1,DATE2;
String TIME;
float V,I,P,E,f,PF;
String weekDays[7] ={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String months[12]  ={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
String sec[60]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String mini[60]    ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String hou[24]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
String myIP;
float h,t;
char ssid[] = "ruethai2518";
char pass[] = "stang3012";
char auth[] = "jAVk6afL321RcB3wDPHBrkvh0Fyi7cGd";
void setup() 
{
  Serial.begin(115200);
  dht.begin();
  Serial.println(); 
  WiFi.mode(WIFI_STA);
   WiFi.begin("ruethai2518","stang3012");                 //  ต้องใส่ชื่อ wifi และ password
  while (WiFi.status() != WL_CONNECTED)   //รอจนกว่าจะเชื่อมต่อสำเร็จ
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(""); 
  Serial.println("WiFi connected");  
  server.begin();
  Serial.print("Server IP Address : "); 
  myIP = ipToString( WiFi.localIP() );
  Serial.println( WiFi.localIP());
  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov");  // ดึงเวลาจากserver 
  Blynk.begin(auth, ssid, pass, "oasiskit.com",8080);
}


void loop() 
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Connecting To   : "); 
  Serial.println(WiFi.SSID()); 
  
  Serial.print("IP Address      : ");
  Serial.println(myIP); 

  Serial.print("Signal Strength : ");
  Serial.print(WiFi.RSSI());
  Serial.println(" dBm");
  
  time_t now;
  time(&now);
  struct tm *p_tm = localtime(&now);
 
TIME  = String(hou[(p_tm->tm_hour)]) + ":" + String(mini[(p_tm->tm_min)])     + ":" + String(sec[(p_tm->tm_sec)]);
DATE1 = String(p_tm->tm_mday)        + "/" + String((p_tm->tm_mon)+1)         + "/" + String(p_tm->tm_year+1900);
DATE2 = String(p_tm->tm_mday)        + " " + String(months[(p_tm->tm_mon)])   + " " + String(p_tm->tm_year+1900);

  Serial.print("Date            : ");
  Serial.println(DATE1);  
  Serial.print("Date            : ");
  Serial.println(DATE2);
  Serial.print("Day             : ");
  DAY = weekDays[(p_tm->tm_wday)];
  Serial.println(DAY);
  Serial.print("Time            : ");
  Serial.println(TIME);
  Serial.print("Humidity        : ");
  Serial.println(h);
  Serial.print("Temperature     : ");
  Serial.println(t);
  Serial.println();
  Web();
  Serial.print("Custom Address:");
    Serial.println(pzem.readAddress(), HEX);

    // Read the data from the sensor
    float V = pzem.voltage();
    float I = pzem.current();
    float P = pzem.power();
    float E = pzem.energy();
    float f = pzem.frequency();
    float PF = pzem.pf();

    // Check if the data is valid
    if(isnan(V)){
        Serial.println("Error reading voltage");
    } else if (isnan(I)) {
        Serial.println("Error reading current");
    } else if (isnan(P)) {
        Serial.println("Error reading power");
    } else if (isnan(E)) {
        Serial.println("Error reading energy");
    } else if (isnan(f)) {
        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(V);      Serial.println("V");
        Serial.print("Current: ");      Serial.print(I);      Serial.println("A");
        Serial.print("Power: ");        Serial.print(P);        Serial.println("W");
        Serial.print("Energy: ");       Serial.print(E,3);     Serial.println("kWh");
        Serial.print("Frequency: ");    Serial.print(f, 1); Serial.println("Hz");
        Serial.print("PF: ");           Serial.println(PF);
    }
Blynk.run();
  Blynk.virtualWrite(V0,DAY);
  Blynk.virtualWrite(V1,TIME);
  Blynk.virtualWrite(V2,DATE1);
  Blynk.virtualWrite(V3,DATE2);
  Blynk.virtualWrite(V4,h);
  Blynk.virtualWrite(V5,t);
  Blynk.virtualWrite(V6,V);
  Blynk.virtualWrite(V7,I);
  Blynk.virtualWrite(V8,P);
  Blynk.virtualWrite(V9,E);
  Blynk.virtualWrite(V10,f);
  Blynk.virtualWrite(V11,PF);
  delay(1000);
}

String ipToString(IPAddress ip)
{
  String s="";
  for (int i=0; i<4; i++)
    s += i  ? "." + String(ip[i]) : String(ip[i]);
  return s;
}
void Web()
{
  
  client = server.available(); 
  float h = dht.readHumidity();
  float t = dht.readTemperature();    
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Connection: close");    // the connection will be closed after completion of the response
  client.println("Refresh: 5");           // refresh the page automatically every 5 sec
  client.println();
  client.println("<!DOCTYPE html>");
  client.println("<head>\n<meta charset='UTF-8'>");
  client.println("<title>A Development of IoT for Energy Management System</title>");
  client.println("</head>\n<body>");
  client.println("<H3>");
  client.println("A Development of IoT for Energy Management System</BR>");
  client.println("Department of Electrical Engineering, KMUTT</BR>");
  client.println("<H3>Power and Energy Measurement</H3>"); 
  client.println("<pre>");
  client.println("</B>");
  client.println("WiFi Network Name : " + String(ssid));
  client.print("Signal Strength   :  "); 
  client.print(WiFi.RSSI());
  client.println("dB "); 
  client.println("IP Address: "+ String(myIP));
  client.print("Humidity: " +String(h));
  client.println(" %");
  client.print("Temperature: "  +String(t));
  client.println(" C");
  client.println("</B>"); 
  client.println(DAY);   
  client.println(DATE1);
  client.println(DATE2);   
  client.println(TIME);  
  client.println(h);
  client.println(t);
  client.println(V);  
  client.println(I);
  client.println(P);
  client.println(E);
  client.println(f);
  client.println(PF);

  client.println( );   
  client.println("<H3>Our Data Communicate Through NodeMCU V3</H3>");
  client.println("</pre>");    
  client.println("</body>\n</html>");
}

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

Sawadee Khap @Windbreeze_TH :pray:

What does your serial monitor show? (reboot the device and watch the WiFi and Blynk connection process, then see what readings you get).
This will give you some clues about what is happening.

The advice from @John93 is very good. Your void loop needs changing and you need to remove the

command and use a BlynkTimer to execute the code that takes the readings.

Pete.

@PeteKnight @John93 Thank you for your advice. i already change the code and the result is still the same.
P.S. the photo of the serial monitor is down below and the photo of the blynk will be post in another reply.

#define  BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Time.h>
#include <PZEM004Tv30.h>
#include <SoftwareSerial.h>
#include "DHT.h"
#define DHTPIN D2
#define DHTTYPE DHT22
#if defined(ESP32)
    #error "Software Serial is not supported on the ESP32"
#endif
#if !defined(PZEM_RX_PIN) && !defined(PZEM_TX_PIN)
#define PZEM_RX_PIN D3
#define PZEM_TX_PIN D4
#endif


SoftwareSerial pzemSWSerial(PZEM_RX_PIN, PZEM_TX_PIN);
PZEM004Tv30 pzem(pzemSWSerial);

DHT dht(DHTPIN, DHTTYPE);
WiFiClient client;
WiFiServer server(80);
BlynkTimer timer; // Announcing the timer

int    timezone    = 7 * 3600;        // ตั้งค่า timezone
int    dst         = 0;               // ตั้งค่า daylight saving time 
int    SignalStrength;
String DAY;
String DATE1,DATE2;
String TIME;
float V,I,P,E,f,PF;
String weekDays[7] ={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String months[12]  ={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
String sec[60]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String mini[60]    ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String hou[24]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
String myIP;
float h,t;
char ssid[] = "ruethai2518";
char pass[] = "stang3012";
char auth[] = "jAVk6afL321RcB3wDPHBrkvh0Fyi7cGd";
void setup() 
{
  Serial.begin(115200);
  dht.begin();
  Serial.println(); 
  WiFi.mode(WIFI_STA);
   WiFi.begin("ruethai2518","stang3012");                 //  ต้องใส่ชื่อ wifi และ password
  while (WiFi.status() != WL_CONNECTED)   //รอจนกว่าจะเชื่อมต่อสำเร็จ
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(""); 
  Serial.println("WiFi connected");  
  server.begin();
  Serial.print("Server IP Address : "); 
  myIP = ipToString( WiFi.localIP() );
  Serial.println( WiFi.localIP());
  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov");  // ดึงเวลาจากserver 
  Blynk.begin(auth, ssid, pass, "oasiskit.com",8080);
  timer.setInterval(1000L, update); //timer will run every sec
}

void update()
{
float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Connecting To   : "); 
  Serial.println(WiFi.SSID()); 
  
  Serial.print("IP Address      : ");
  Serial.println(myIP); 

  Serial.print("Signal Strength : ");
  Serial.print(WiFi.RSSI());
  Serial.println(" dBm");
  
  time_t now;
  time(&now);
  struct tm *p_tm = localtime(&now);
 
TIME  = String(hou[(p_tm->tm_hour)]) + ":" + String(mini[(p_tm->tm_min)])     + ":" + String(sec[(p_tm->tm_sec)]);
DATE1 = String(p_tm->tm_mday)        + "/" + String((p_tm->tm_mon)+1)         + "/" + String(p_tm->tm_year+1900);
DATE2 = String(p_tm->tm_mday)        + " " + String(months[(p_tm->tm_mon)])   + " " + String(p_tm->tm_year+1900);

  Serial.print("Date            : ");
  Serial.println(DATE1);  
  Serial.print("Date            : ");
  Serial.println(DATE2);
  Serial.print("Day             : ");
  DAY = weekDays[(p_tm->tm_wday)];
  Serial.println(DAY);
  Serial.print("Time            : ");
  Serial.println(TIME);
  Serial.print("Humidity        : ");
  Serial.println(h);
  Serial.print("Temperature     : ");
  Serial.println(t);
  Serial.println();
  Web();
  Serial.print("Custom Address:");
    Serial.println(pzem.readAddress(), HEX);

    // Read the data from the sensor
    float V = pzem.voltage();
    float I = pzem.current();
    float P = pzem.power();
    float E = pzem.energy();
    float f = pzem.frequency();
    float PF = pzem.pf();

    // Check if the data is valid
    if(isnan(V)){
        Serial.println("Error reading voltage");
    } else if (isnan(I)) {
        Serial.println("Error reading current");
    } else if (isnan(P)) {
        Serial.println("Error reading power");
    } else if (isnan(E)) {
        Serial.println("Error reading energy");
    } else if (isnan(f)) {
        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(V);      Serial.println("V");
        Serial.print("Current: ");      Serial.print(I);      Serial.println("A");
        Serial.print("Power: ");        Serial.print(P);        Serial.println("W");
        Serial.print("Energy: ");       Serial.print(E,3);     Serial.println("kWh");
        Serial.print("Frequency: ");    Serial.print(f, 1); Serial.println("Hz");
        Serial.print("PF: ");           Serial.println(PF);
    }
  Blynk.virtualWrite(V0,DAY);
  Blynk.virtualWrite(V1,TIME);
  Blynk.virtualWrite(V2,DATE1);
  Blynk.virtualWrite(V3,DATE2);
  Blynk.virtualWrite(V4,h);
  Blynk.virtualWrite(V5,t);
  Blynk.virtualWrite(V6,V);
  Blynk.virtualWrite(V7,I);
  Blynk.virtualWrite(V8,P);
  Blynk.virtualWrite(V9,E);
  Blynk.virtualWrite(V10,f);
  Blynk.virtualWrite(V11,PF);
}
void loop() 
{ 
Blynk.run();
timer.run();        // run timer every second

}

String ipToString(IPAddress ip)
{
  String s="";
  for (int i=0; i<4; i++)
    s += i  ? "." + String(ip[i]) : String(ip[i]);
  return s;
}
void Web()
{
  
  client = server.available(); 
  float h = dht.readHumidity();
  float t = dht.readTemperature();    
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Connection: close");    // the connection will be closed after completion of the response
  client.println("Refresh: 5");           // refresh the page automatically every 5 sec
  client.println();
  client.println("<!DOCTYPE html>");
  client.println("<head>\n<meta charset='UTF-8'>");
  client.println("<title>A Development of IoT for Energy Management System</title>");
  client.println("</head>\n<body>");
  client.println("<H3>");
  client.println("A Development of IoT for Energy Management System</BR>");
  client.println("Department of Electrical Engineering, KMUTT</BR>");
  client.println("<H3>Power and Energy Measurement</H3>"); 
  client.println("<pre>");
  client.println("</B>");
  client.println("WiFi Network Name : " + String(ssid));
  client.print("Signal Strength   :  "); 
  client.print(WiFi.RSSI());
  client.println("dB "); 
  client.println("IP Address: "+ String(myIP));
  client.print("Humidity: " +String(h));
  client.println(" %");
  client.print("Temperature: "  +String(t));
  client.println(" C");
  client.println("</B>"); 
  client.println(DAY);   
  client.println(DATE1);
  client.println(DATE2);   
  client.println(TIME);  
  client.println(h);
  client.println(t);
  client.println(V);  
  client.println(I);
  client.println(P);
  client.println(E);
  client.println(f);
  client.println(PF);

  client.println( );   
  client.println("<H3>Our Data Communicate Through NodeMCU V3</H3>");
  client.println("</pre>");    
  client.println("</body>\n</html>");
}

This is the other time section. The data of power and energy graph, I click delete the data. But the other two graph, it was the data of yesterday that was still shown and not updated as you can see it didn’t fit with the data right now.

This part of your sketch is very confusing. Your device is not re-connecting to your WiFi each time you run the update function, it’s connecting once, when the device starts-up and runs void setup.
That lines of code that follow are also unnecessary, as you don’t really need to know your RSSI and time/date each time you take a reading.
I would think that these lines of code should be in your void setup.

It’s always best to highlight the text in the serial monitor then copy it (CTRL-A) and paste it into your forum post with triple backticks at the beginning and end, the same as when you post code.
I really wanted to see the information from the serial monitor when the devices boots and connects to the Blynk server, then starts to display the readings.

Pete.

......
WiFi connected
Server IP Address : 192.168.1.46
[5300] Connecting to ruethai2518
[5300] Connected to WiFi
[5300] IP: 192.168.1.46
[5300] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP8266

[5313] Connecting to oasiskit.com:8080
[5397] Ready (ping: 35ms).
Connecting To   : ruethai2518
IP Address      : 192.168.1.46
Signal Strength : -60 dBm
Date            : 17/10/2022
Date            : 17 October 2022
Day             : Monday
Time            : 15:41:03
Humidity        : 77.50
Temperature     : 27.60

Custom Address:1
Voltage: 231.20V
Current: 0.06A
Power: 6.60W
Energy: 0.453kWh
Frequency: 50.0Hz
PF: 0.46
Connecting To   : ruethai2518
IP Address      : 192.168.1.46
Signal Strength : -64 dBm
Date            : 17/10/2022
Date            : 17 October 2022
Day             : Monday
Time            : 15:41:04
Humidity        : 77.50
Temperature     : 27.60

And we need to see the code that prodipuced this serial output.

Pete.

#define  BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Time.h>
#include <PZEM004Tv30.h>
#include <SoftwareSerial.h>
#include "DHT.h"
#define DHTPIN D2
#define DHTTYPE DHT22
#if defined(ESP32)
    #error "Software Serial is not supported on the ESP32"
#endif
#if !defined(PZEM_RX_PIN) && !defined(PZEM_TX_PIN)
#define PZEM_RX_PIN D3
#define PZEM_TX_PIN D4
#endif


SoftwareSerial pzemSWSerial(PZEM_RX_PIN, PZEM_TX_PIN);
PZEM004Tv30 pzem(pzemSWSerial);

DHT dht(DHTPIN, DHTTYPE);
WiFiClient client;
WiFiServer server(80);
BlynkTimer timer; // Announcing the timer

int    timezone    = 7 * 3600;        // ตั้งค่า timezone
int    dst         = 0;               // ตั้งค่า daylight saving time 
int    SignalStrength;
String DAY;
String DATE1,DATE2;
String TIME;
float V,I,P,E,f,PF;
String weekDays[7] ={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String months[12]  ={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
String sec[60]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String mini[60]    ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
String hou[24]     ={"00", "01", "02", "03", "04", "05", "06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
String myIP;
float h,t;
char ssid[] = "ruethai2518";
char pass[] = "stang3012";
char auth[] = "jAVk6afL321RcB3wDPHBrkvh0Fyi7cGd";
void setup() 
{
  Serial.begin(115200);
  dht.begin();
  Serial.println(); 
  WiFi.mode(WIFI_STA);
   WiFi.begin("ruethai2518","stang3012");                 //  ต้องใส่ชื่อ wifi และ password
  while (WiFi.status() != WL_CONNECTED)   //รอจนกว่าจะเชื่อมต่อสำเร็จ
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(""); 
  Serial.println("WiFi connected");  
  server.begin();
  Serial.print("Server IP Address : "); 
  myIP = ipToString( WiFi.localIP() );
  Serial.println( WiFi.localIP());
  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov");  // ดึงเวลาจากserver 
  Blynk.begin(auth, ssid, pass, "oasiskit.com",8080);
  timer.setInterval(1000L, update); //timer will run every sec
}

void update()
{
float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Connecting To   : "); 
  Serial.println(WiFi.SSID()); 
  
  Serial.print("IP Address      : ");
  Serial.println(myIP); 

  Serial.print("Signal Strength : ");
  Serial.print(WiFi.RSSI());
  Serial.println(" dBm");
  
  time_t now;
  time(&now);
  struct tm *p_tm = localtime(&now);
 
TIME  = String(hou[(p_tm->tm_hour)]) + ":" + String(mini[(p_tm->tm_min)])     + ":" + String(sec[(p_tm->tm_sec)]);
DATE1 = String(p_tm->tm_mday)        + "/" + String((p_tm->tm_mon)+1)         + "/" + String(p_tm->tm_year+1900);
DATE2 = String(p_tm->tm_mday)        + " " + String(months[(p_tm->tm_mon)])   + " " + String(p_tm->tm_year+1900);

  Serial.print("Date            : ");
  Serial.println(DATE1);  
  Serial.print("Date            : ");
  Serial.println(DATE2);
  Serial.print("Day             : ");
  DAY = weekDays[(p_tm->tm_wday)];
  Serial.println(DAY);
  Serial.print("Time            : ");
  Serial.println(TIME);
  Serial.print("Humidity        : ");
  Serial.println(h);
  Serial.print("Temperature     : ");
  Serial.println(t);
  Serial.println();
  Web();
  Serial.print("Custom Address:");
    Serial.println(pzem.readAddress(), HEX);

    // Read the data from the sensor
     V = pzem.voltage();
     I = pzem.current();
     P = pzem.power();
     E = pzem.energy();
     f = pzem.frequency();
     PF = pzem.pf();

    // Check if the data is valid
    if(isnan(V)){
        Serial.println("Error reading voltage");
    } else if (isnan(I)) {
        Serial.println("Error reading current");
    } else if (isnan(P)) {
        Serial.println("Error reading power");
    } else if (isnan(E)) {
        Serial.println("Error reading energy");
    } else if (isnan(f)) {
        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(V);      Serial.println("V");
        Serial.print("Current: ");      Serial.print(I);      Serial.println("A");
        Serial.print("Power: ");        Serial.print(P);        Serial.println("W");
        Serial.print("Energy: ");       Serial.print(E,3);     Serial.println("kWh");
        Serial.print("Frequency: ");    Serial.print(f, 1); Serial.println("Hz");
        Serial.print("PF: ");           Serial.println(PF);
    }
  Blynk.virtualWrite(V0,DAY);
  Blynk.virtualWrite(V1,TIME);
  Blynk.virtualWrite(V2,DATE1);
  Blynk.virtualWrite(V3,DATE2);
  Blynk.virtualWrite(V4,h);
  Blynk.virtualWrite(V5,t);
  Blynk.virtualWrite(V6,V);
  Blynk.virtualWrite(V7,I);
  Blynk.virtualWrite(V8,P);
  Blynk.virtualWrite(V9,E);
  Blynk.virtualWrite(V10,f);
  Blynk.virtualWrite(V11,PF);
}
void loop() 
{ 
Blynk.run();
timer.run();        // run timer every second

}

String ipToString(IPAddress ip)
{
  String s="";
  for (int i=0; i<4; i++)
    s += i  ? "." + String(ip[i]) : String(ip[i]);
  return s;
}
void Web()
{
  
  client = server.available(); 
  float h = dht.readHumidity();
  float t = dht.readTemperature();    
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Connection: close");    // the connection will be closed after completion of the response
  client.println("Refresh: 5");           // refresh the page automatically every 5 sec
  client.println();
  client.println("<!DOCTYPE html>");
  client.println("<head>\n<meta charset='UTF-8'>");
  client.println("<title>A Development of IoT for Energy Management System</title>");
  client.println("</head>\n<body>");
  client.println("<H3>");
  client.println("A Development of IoT for Energy Management System</BR>");
  client.println("Department of Electrical Engineering, KMUTT</BR>");
  client.println("<H3>Power and Energy Measurement</H3>"); 
  client.println("<pre>");
  client.println("</B>");
  client.println("WiFi Network Name : " + String(ssid));
  client.print("Signal Strength   :  "); 
  client.print(WiFi.RSSI());
  client.println("dB "); 
  client.println("IP Address: "+ String(myIP));
  client.print("Humidity: " +String(h));
  client.println(" %");
  client.print("Temperature: "  +String(t));
  client.println(" C");
  client.println("</B>"); 
  client.println(DAY);   
  client.println(DATE1);
  client.println(DATE2);   
  client.println(TIME);  
  client.println(h);
  client.println(t);
  client.println(V);  
  client.println(I);
  client.println(P);
  client.println(E);
  client.println(f);
  client.println(PF);

  client.println( );   
  client.println("<H3>Our Data Communicate Through NodeMCU V3</H3>");
  client.println("</pre>");    
  client.println("</body>\n</html>");
}

I’m getting confused with the screenshots that you’ve posted, and what you’ve said about

Can you erase the data from the Supercharts and explain what happens when you boot-up your device, in both the Live an 1 Hour screens?
Remember that it takes at least one minute before data appears in the 1 hour screen, and the data that is displayed is the average of all the readings that were sent to the server over the previous 60 seconds.

Pete.

Ok. So I delete all the the data ,boot-up the graph and wait more than 1 minutes but it was like the data from live hadn’t been collected to 1 hr or any longert time period.


@PeteKnight this is it.

Maybe it’s an issue with the local server then?
The server should be taking the readings, averaging them out to create the one minute readings and averaging these out to create the create the one hour readings which are used in the 1 Day, 1 Week, 1 Month etc timescales.

My guess is that the server has run out of storage space and is not creating these 1 minute averaged files, or the process that creates the files has stopped working.
If it’s the latter then rebooting the local server should fix it, otherwise whoever manages the server will need to so some cleaning-up.

If the server is a Raspberry Pi with an SD card then it’s possible that the SD card is failing.

Pete.

Thanks a lot. I found that it was a server problem. So, I have to change the server. And again thanks a lot. That’s a very king of you.:pray::sparkles::sparkling_heart:

1 Like

Kap khun krap :pray:

Pete.

1 Like