Looking for freelance programmer using arduino IDE + Blynk

looking for freelance programmer using arduino IDE + Blynk

hi all,

I have a project to make HVAC system analog control panel smart using arduino Mega 2560 and blynk apps.

my method is to use the current sensor and tap at Pilot Lamp at control panel. because at control panel have a Green and red pilot lamp. each pilot lamp indicates system running (green) or down (red).

So each pair of the pilot lamps will connect to every protection system in the control panel. By using IOT to the control panel, we can monitor specific devices that down far from the site.

The method is - if device A down, the current will supply to Red Pilot Lamp and current sensor detects current will sent signal to Mega 2560. end of signal, Blynk will show the device down from the current detect at pilot lamp.

My coding: apps at blynk will show downtime and total running time. If the current sensor not install at the board, it will detect system down. Unless current sensor connected to Mega and detect current at red pilot lamp, so the system really down.

my project has a few bugs and needs amendment on the programming. here is below my plan to amend

  1. My total downtime & running time change and not running properly in Blynk. refer screenshot

  2. need a function to reset runtime

  3. change networking from using wifi to gsm. Alternative if the area doesn’t have wifi and need to use gsm internet.

if anyone can alter for me as per above, kindly email me at faizalh@unsurhebat.com we will discuss about the payment.

refer attachment for the coding on the current project.


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

const int sensorIn1 = A0;
int mVperAmp1 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage1 = 0;
double VRMS1 = 0;
double AmpsRMS1 = 0;

const int sensorIn2 = A1;
int mVperAmp2 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage2 = 0;
double VRMS2 = 0;
double AmpsRMS2 = 0;

const int sensorIn3 = A2;
int mVperAmp3 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage3 = 0;
double VRMS3 = 0;
double AmpsRMS3 = 0;

const int sensorIn4 = A3;
int mVperAmp4 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage4 = 0;
double VRMS4 = 0;
double AmpsRMS4 = 0;

const int sensorIn5 = A4;
int mVperAmp5 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage5 = 0;
double VRMS5 = 0;
double AmpsRMS5 = 0;

const int sensorIn6 = A5;
int mVperAmp6 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage6 = 0;
double VRMS6 = 0;
double AmpsRMS6 = 0;

const int sensorIn7 = A6;
int mVperAmp7 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage7 = 0;
double VRMS7 = 0;
double AmpsRMS7 = 0;

const int sensorIn8 = A7;
int mVperAmp8 = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage8 = 0;
double VRMS8 = 0;
double AmpsRMS8 = 0;

WidgetLED led11(V1);
WidgetLED led12(V3);
WidgetLED led21(V5);
WidgetLED led22(V6);
WidgetLED led31(V9);
WidgetLED led32(V10);
WidgetLED led41(V13);
WidgetLED led42(V14);
WidgetLED led51(V17);
WidgetLED led52(V18);
WidgetLED led61(V21);
WidgetLED led62(V22);
WidgetLED led71(V25);
WidgetLED led72(V26);
WidgetLED led81(V29);
WidgetLED led82(V30);
BlynkTimer timer;

//first sensor
int runHours;
int runMinutes;
int runSeconds;
int secsRemaining;
int runHours2;
int runMinutes2;
int runSeconds2;
int secsRemaining2;

char DownDur[21];
char RunTime[21];
char DownTime[21];

unsigned long startMillis;
unsigned long endMillis;
unsigned long countMillis;
unsigned long startMillis2;
unsigned long endMillis2;
unsigned long duration;
unsigned long duration2;
unsigned long duration3;
unsigned long duration4;
unsigned long allSeconds;
unsigned long allSeconds2;

//second sensor
int runHours21;
int runMinutes21;
int runSeconds21;
int secsRemaining21;
int runHours22;
int runMinutes22;
int runSeconds22;
int secsRemaining22;

char DownDur2[21];
char RunTime2[21];
char DownTime2[21];

unsigned long startMillis21;
unsigned long endMillis21;
unsigned long countMillis21;
unsigned long startMillis22;
unsigned long endMillis22;
unsigned long countMillis2;
unsigned long duration21;
unsigned long duration22;
unsigned long duration23;
unsigned long duration24;
unsigned long allSeconds21;
unsigned long allSeconds22;

//3rd sensor
int runHours31;
int runMinutes31;
int runSeconds31;
int secsRemaining31;
int runHours32;
int runMinutes32;
int runSeconds32;
int secsRemaining32;

char DownDur3[21];
char RunTime3[21];
char DownTime3[21];

unsigned long startMillis31;
unsigned long endMillis31;
unsigned long startMillis32;
unsigned long endMillis32;
unsigned long countMillis3;
unsigned long duration31;
unsigned long duration32;
unsigned long duration33;
unsigned long duration34;
unsigned long allSeconds31;
unsigned long allSeconds32;

//4th sensor
int runHours41;
int runMinutes41;
int runSeconds41;
int secsRemaining41;
int runHours42;
int runMinutes42;
int runSeconds42;
int secsRemaining42;

char DownDur4[21];
char RunTime4[21];
char DownTime4[21];

unsigned long startMillis41;
unsigned long endMillis41;
unsigned long startMillis42;
unsigned long endMillis42;
unsigned long countMillis4;
unsigned long duration41;
unsigned long duration42;
unsigned long duration43;
unsigned long duration44;
unsigned long allSeconds41;
unsigned long allSeconds42;

//5th sensor
int runHours51;
int runMinutes51;
int runSeconds51;
int secsRemaining51;
int runHours52;
int runMinutes52;
int runSeconds52;
int secsRemaining52;

char DownDur5[21];
char RunTime5[21];
char DownTime5[21];

unsigned long startMillis51;
unsigned long endMillis51;
unsigned long startMillis52;
unsigned long endMillis52;
unsigned long countMillis5;
unsigned long duration51;
unsigned long duration52;
unsigned long duration53;
unsigned long duration54;
unsigned long allSeconds51;
unsigned long allSeconds52;

//6th sensor
int runHours61;
int runMinutes61;
int runSeconds61;
int secsRemaining61;
int runHours62;
int runMinutes62;
int runSeconds62;
int secsRemaining62;

char DownDur6[21];
char RunTime6[21];
char DownTime6[21];

unsigned long startMillis61;
unsigned long endMillis61;
unsigned long startMillis62;
unsigned long endMillis62;
unsigned long countMillis6;
unsigned long duration61;
unsigned long duration62;
unsigned long duration63;
unsigned long duration64;
unsigned long allSeconds61;
unsigned long allSeconds62;

//7th sensor
int runHours71;
int runMinutes71;
int runSeconds71;
int secsRemaining71;
int runHours72;
int runMinutes72;
int runSeconds72;
int secsRemaining72;

char DownDur7[21];
char RunTime7[21];
char DownTime7[21];

unsigned long startMillis71;
unsigned long endMillis71;
unsigned long startMillis72;
unsigned long endMillis72;
unsigned long countMillis7;
unsigned long duration71;
unsigned long duration72;
unsigned long duration73;
unsigned long duration74;
unsigned long allSeconds71;
unsigned long allSeconds72;

//8th sensor
int runHours81;
int runMinutes81;
int runSeconds81;
int secsRemaining81;
int runHours82;
int runMinutes82;
int runSeconds82;
int secsRemaining82;

char DownDur8[21];
char RunTime8[21];
char DownTime8[21];

unsigned long startMillis81;
unsigned long endMillis81;
unsigned long startMillis82;
unsigned long endMillis82;
unsigned long countMillis8;
unsigned long duration81;
unsigned long duration82;
unsigned long duration83;
unsigned long duration84;
unsigned long allSeconds81;
unsigned long allSeconds82;
void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(1000L, blinkLedWidget1);
  timer.setInterval(1000L, blinkLedWidget2);
  timer.setInterval(1000L, blinkLedWidget3);
  timer.setInterval(1000L, blinkLedWidget4);
  timer.setInterval(1000L, blinkLedWidget5);
  timer.setInterval(1000L, blinkLedWidget6);
  timer.setInterval(1000L, blinkLedWidget7);
  timer.setInterval(1000L, blinkLedWidget8);
}

void loop()
{
  Blynk.run();
  timer.run();
}

void blinkLedWidget1()
{
  countMillis = millis();
  Voltage1 = getVPP1();
  VRMS1 = (Voltage1 / 2.0) * 0.707;
  AmpsRMS1 = (VRMS1 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS1);
  Serial.println(" Amps RMS");

  if (AmpsRMS1 < 0.30) {
    led11.off();
    led12.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis = millis(); // Stop the counting
    endMillis2 = millis();
    duration4 = endMillis2 - startMillis2;
    duration2 = duration2 + duration;
    duration = 0;

    allSeconds2 = (countMillis - duration2) / 1000;
    secsRemaining2 = allSeconds2 % 86400;
    runHours2 = secsRemaining2 / 3600;
    secsRemaining2 = allSeconds2 % 3600;
    runMinutes2 = secsRemaining2 / 60;
    runSeconds2 = secsRemaining2 % 60;
    sprintf(RunTime, "Total Run Time: %02d:%02d:%02d", runHours2, runMinutes2, runSeconds2);
    Blynk.virtualWrite(V4, RunTime); // running hours

  }
  else
  {
    led11.on();  //lampu merah on
    led12.off();
    Serial.println("LED on V1: on");
    Blynk.notify("ACCU E77B down");
    startMillis2 = millis();
    endMillis = millis();
    duration = endMillis - startMillis;
    duration3 = duration3 + duration4;
    duration4 = 0;
    allSeconds = (countMillis - duration3) / 1000;
    secsRemaining = allSeconds % 86400;
    runHours = secsRemaining / 3600;
    secsRemaining = allSeconds % 3600;
    runMinutes = secsRemaining / 60;
    runSeconds = secsRemaining % 60;
    sprintf(DownTime, "Total Down Time: %02d:%02d:%02d", runHours, runMinutes, runSeconds);
    Blynk.virtualWrite(V2, DownTime); // hours breakdown
  }
}

float getVPP1()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn1);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget2()
{
  countMillis2 = millis();
  Voltage2 = getVPP2();
  VRMS2 = (Voltage2 / 2.0) * 0.707;
  AmpsRMS2 = (VRMS2 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS2);
  Serial.println(" Amps RMS");

  if (AmpsRMS2 < 0.30) {
    led21.off();
    led22.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis21 = millis(); // Stop the counting
    endMillis22 = millis();
    duration24 = endMillis22 - startMillis22;
    duration22 = duration22 + duration21;
    duration21 = 0;

    allSeconds22 = (countMillis2 - duration22) / 1000;
    secsRemaining22 = allSeconds22 % 86400;
    runHours22 = secsRemaining22 / 3600;
    secsRemaining22 = allSeconds22 % 3600;
    runMinutes22 = secsRemaining22 / 60;
    runSeconds22 = secsRemaining22 % 60;
    sprintf(RunTime2, "Total Run Time: %02d:%02d:%02d", runHours22, runMinutes22, runSeconds22);
    Blynk.virtualWrite(V8, RunTime2); // running hours

  }
  else
  {
    led21.on();  //lampu merah on
    led22.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 1 down");
    startMillis22 = millis();
    endMillis21 = millis();
    duration21 = endMillis21 - startMillis21;
    duration23 = duration23 + duration24;
    duration24 = 0;
    allSeconds21 = (countMillis2 - duration23) / 1000;
    secsRemaining21 = allSeconds21 % 86400;
    runHours21 = secsRemaining21 / 3600;
    secsRemaining21 = allSeconds21 % 3600;
    runMinutes21 = secsRemaining21 / 60;
    runSeconds21 = secsRemaining21 % 60;
    sprintf(DownTime2, "Total Down Time: %02d:%02d:%02d", runHours21, runMinutes21, runSeconds21);
    Blynk.virtualWrite(V7, DownTime2); // hours breakdown
  }

}

float getVPP2()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn2);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget3()
{
  countMillis3 = millis();
  Voltage3 = getVPP3();
  VRMS3 = (Voltage3 / 2.0) * 0.707;
  AmpsRMS3 = (VRMS3 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS3);
  Serial.println(" Amps RMS");

  if (AmpsRMS3 < 0.30) {
    led31.off();
    led32.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis31 = millis(); // Stop the counting
    endMillis32 = millis();
    duration34 = endMillis32 - startMillis32;
    duration32 = duration32 + duration31;
    duration31 = 0;

    allSeconds32 = (countMillis3 - duration32) / 1000;
    secsRemaining32 = allSeconds32 % 86400;
    runHours32 = secsRemaining32 / 3600;
    secsRemaining32 = allSeconds32 % 3600;
    runMinutes32 = secsRemaining32 / 60;
    runSeconds32 = secsRemaining32 % 60;
    sprintf(RunTime3, "Total Run Time: %02d:%02d:%02d", runHours32, runMinutes32, runSeconds32);
    Blynk.virtualWrite(V12, RunTime3); // running hours

  }
  else
  {
    led31.on();  //lampu merah on
    led32.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 3 down");
    startMillis32 = millis();
    endMillis31 = millis();
    duration31 = endMillis31 - startMillis31;
    duration33 = duration33 + duration34;
    duration34 = 0;
    allSeconds31 = (countMillis3 - duration33) / 1000;
    secsRemaining31 = allSeconds31 % 86400;
    runHours31 = secsRemaining31 / 3600;
    secsRemaining31 = allSeconds31 % 3600;
    runMinutes31 = secsRemaining31 / 60;
    runSeconds31 = secsRemaining31 % 60;
    sprintf(DownTime3, "Total Down Time: %02d:%02d:%02d", runHours31, runMinutes31, runSeconds31);
    Blynk.virtualWrite(V11, DownTime3); // hours breakdown
  }

}

float getVPP3()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn3);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget4()
{
  countMillis4 = millis();
  Voltage4 = getVPP4();
  VRMS4 = (Voltage4 / 2.0) * 0.707;
  AmpsRMS4 = (VRMS4 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS4);
  Serial.println(" Amps RMS");

  if (AmpsRMS4 < 0.30) {
    led41.off();
    led42.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis41 = millis(); // Stop the counting
    endMillis42 = millis();
    duration44 = endMillis42 - startMillis42;
    duration42 = duration42 + duration41;
    duration41 = 0;

    allSeconds42 = (countMillis4 - duration42) / 1000;
    secsRemaining42 = allSeconds42 % 86400;
    runHours42 = secsRemaining42 / 3600;
    secsRemaining42 = allSeconds42 % 3600;
    runMinutes42 = secsRemaining42 / 60;
    runSeconds42 = secsRemaining42 % 60;
    sprintf(RunTime4, "Total Run Time: %02d:%02d:%02d", runHours42, runMinutes42, runSeconds42);
    Blynk.virtualWrite(V16, RunTime4); // running hours

  }
  else
  {
    led41.on();  //lampu merah on
    led42.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 4 down");
    startMillis42 = millis();
    endMillis41 = millis();
    duration41 = endMillis41 - startMillis41;
    duration43 = duration43 + duration44;
    duration44 = 0;
    allSeconds41 = (countMillis4 - duration43) / 1000;
    secsRemaining41 = allSeconds41 % 86400;
    runHours41 = secsRemaining41 / 3600;
    secsRemaining41 = allSeconds41 % 3600;
    runMinutes41 = secsRemaining41 / 60;
    runSeconds41 = secsRemaining41 % 60;
    sprintf(DownTime4, "Total Down Time: %02d:%02d:%02d", runHours41, runMinutes41, runSeconds41);
    Blynk.virtualWrite(V15, DownTime4); // hours breakdown
  }

}

float getVPP4()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn4);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget5()
{
  countMillis5 = millis();
  Voltage5 = getVPP5();
  VRMS5 = (Voltage5 / 2.0) * 0.707;
  AmpsRMS5 = (VRMS5 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS5);
  Serial.println(" Amps RMS");

  if (AmpsRMS5 < 0.30) {
    led51.off();
    led52.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis51 = millis(); // Stop the counting
    endMillis52 = millis();
    duration54 = endMillis52 - startMillis52;
    duration52 = duration52 + duration51;
    duration51 = 0;

    allSeconds52 = (countMillis5 - duration52) / 1000;
    secsRemaining52 = allSeconds52 % 86400;
    runHours52 = secsRemaining52 / 3600;
    secsRemaining52 = allSeconds52 % 3600;
    runMinutes52 = secsRemaining52 / 60;
    runSeconds52 = secsRemaining52 % 60;
    sprintf(RunTime5, "Total Run Time: %02d:%02d:%02d", runHours52, runMinutes52, runSeconds52);
    Blynk.virtualWrite(V20, RunTime5); // running hours

  }
  else
  {
    led51.on();  //lampu merah on
    led52.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 5 down");
    startMillis52 = millis();
    endMillis51 = millis();
    duration51 = endMillis51 - startMillis51;
    duration53 = duration53 + duration54;
    duration54 = 0;
    allSeconds51 = (countMillis5 - duration53) / 1000;
    secsRemaining51 = allSeconds51 % 86400;
    runHours51 = secsRemaining51 / 3600;
    secsRemaining51 = allSeconds51 % 3600;
    runMinutes51 = secsRemaining51 / 60;
    runSeconds51 = secsRemaining51 % 60;
    sprintf(DownTime5, "Total Down Time: %02d:%02d:%02d", runHours51, runMinutes51, runSeconds51);
    Blynk.virtualWrite(V19, DownTime5); // hours breakdown
  }

}

float getVPP5()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn5);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget6()
{
  countMillis6 = millis();
  Voltage6 = getVPP6();
  VRMS6 = (Voltage6 / 2.0) * 0.707;
  AmpsRMS6 = (VRMS6 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS6);
  Serial.println(" Amps RMS");

  if (AmpsRMS6 < 0.30) {
    led61.off();
    led62.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis61 = millis(); // Stop the counting
    endMillis62 = millis();
    duration64 = endMillis62 - startMillis62;
    duration62 = duration62 + duration61;
    duration61 = 0;

    allSeconds62 = (countMillis6 - duration62) / 1000;
    secsRemaining62 = allSeconds62 % 86400;
    runHours62 = secsRemaining62 / 3600;
    secsRemaining62 = allSeconds62 % 3600;
    runMinutes62 = secsRemaining52 / 60;
    runSeconds62 = secsRemaining52 % 60;
    sprintf(RunTime6, "Total Run Time: %02d:%02d:%02d", runHours62, runMinutes62, runSeconds62);
    Blynk.virtualWrite(V24, RunTime6); // running hours

  }
  else
  {
    led61.on();  //lampu merah on
    led62.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 6 down");
    startMillis62 = millis();
    endMillis61 = millis();
    duration61 = endMillis61 - startMillis61;
    duration63 = duration63 + duration64;
    duration64 = 0;
    allSeconds61 = (countMillis6 - duration63) / 1000;
    secsRemaining61 = allSeconds61 % 86400;
    runHours61 = secsRemaining61 / 3600;
    secsRemaining61 = allSeconds61 % 3600;
    runMinutes61 = secsRemaining61 / 60;
    runSeconds61 = secsRemaining61 % 60;
    sprintf(DownTime6, "Total Down Time: %02d:%02d:%02d", runHours61, runMinutes61, runSeconds61);
    Blynk.virtualWrite(V23, DownTime6); // hours breakdown
  }

}

float getVPP6()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn6);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget7()
{
  countMillis7 = millis();
  Voltage7 = getVPP7();
  VRMS7 = (Voltage7 / 2.0) * 0.707;
  AmpsRMS7 = (VRMS7 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS7);
  Serial.println(" Amps RMS");

  if (AmpsRMS7 < 0.30) {
    led71.off();
    led72.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis71 = millis(); // Stop the counting
    endMillis72 = millis();
    duration74 = endMillis72 - startMillis72;
    duration72 = duration72 + duration71;
    duration71 = 0;

    allSeconds72 = (countMillis7 - duration72) / 1000;
    secsRemaining72 = allSeconds72 % 86400;
    runHours72 = secsRemaining72 / 3600;
    secsRemaining72 = allSeconds72 % 3600;
    runMinutes72 = secsRemaining72 / 60;
    runSeconds72 = secsRemaining72 % 60;
    sprintf(RunTime7, "Total Run Time: %02d:%02d:%02d", runHours72, runMinutes72, runSeconds72);
    Blynk.virtualWrite(V28, RunTime7); // running hours

  }
  else
  {
    led71.on();  //lampu merah on
    led72.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 7 down");
    startMillis72 = millis();
    endMillis71 = millis();
    duration71 = endMillis71 - startMillis71;
    duration73 = duration73 + duration74;
    duration74 = 0;
    allSeconds71 = (countMillis7 - duration73) / 1000;
    secsRemaining71 = allSeconds71 % 86400;
    runHours71 = secsRemaining71 / 3600;
    secsRemaining71 = allSeconds71 % 3600;
    runMinutes71 = secsRemaining71 / 60;
    runSeconds71 = secsRemaining71 % 60;
    sprintf(DownTime7, "Total Down Time: %02d:%02d:%02d", runHours71, runMinutes71, runSeconds71);
    Blynk.virtualWrite(V27, DownTime7); // hours breakdown
  }

}

float getVPP7()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn7);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}
void blinkLedWidget8()
{
  countMillis8 = millis();
  Voltage8 = getVPP8();
  VRMS8 = (Voltage8 / 2.0) * 0.707;
  AmpsRMS8 = (VRMS8 * 1000) / mVperAmp1;
  Serial.print(AmpsRMS8);
  Serial.println(" Amps RMS");

  if (AmpsRMS8 < 0.30) {
    led81.off();
    led82.on(); //lampu hijau
    Serial.println("LED hijau on");
    startMillis81 = millis(); // Stop the counting
    endMillis82 = millis();
    duration84 = endMillis82 - startMillis82;
    duration82 = duration82 + duration81;
    duration81 = 0;

    allSeconds82 = (countMillis8 - duration82) / 1000;
    secsRemaining82 = allSeconds82 % 86400;
    runHours82 = secsRemaining82 / 3600;
    secsRemaining82 = allSeconds82 % 3600;
    runMinutes82 = secsRemaining82 / 60;
    runSeconds82 = secsRemaining82 % 60;
    sprintf(RunTime8, "Total Run Time: %02d:%02d:%02d", runHours82, runMinutes82, runSeconds82);
    Blynk.virtualWrite(V32, RunTime8); // running hours

  }
  else
  {
    led81.on();  //lampu merah on
    led82.off();
    Serial.println("LED on V1: on");
    Blynk.notify("Compressor 8 down");
    startMillis82 = millis();
    endMillis81 = millis();
    duration81 = endMillis81 - startMillis81;
    duration83 = duration83 + duration84;
    duration84 = 0;
    allSeconds81 = (countMillis8 - duration83) / 1000;
    secsRemaining81 = allSeconds81 % 86400;
    runHours81 = secsRemaining81 / 3600;
    secsRemaining81 = allSeconds81 % 3600;
    runMinutes81 = secsRemaining81 / 60;
    runSeconds81 = secsRemaining81 % 60;
    sprintf(DownTime8, "Total Down Time: %02d:%02d:%02d", runHours81, runMinutes81, runSeconds81);
    Blynk.virtualWrite(V31, DownTime8); // hours breakdown
  }

}

float getVPP8()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

  uint32_t start_time = millis();
  while ((millis() - start_time) < 1000) //sample for 1 Sec
  {
    readValue = analogRead(sensorIn8);
    // see if you have a new maxValue
    if (readValue > maxValue)
    {
      /*record the maximum sensor value*/
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      /*record the maximum sensor value*/
      minValue = readValue;
    }
  }

  // Subtract min from max
  result = ((maxValue - minValue) * 5.0) / 1024.0;

  return result;
}

!

@Faizal_Hads You didn’t format the code as instructed, so I’ve removed it.

Please edit your post using the pencil icon at the bottom and re-add the code with triple backticks at the beginning and end of the code

Pete.

done edit. hopefully can solve it in nearest time