Add int value and increase

Need help for my project
i want to add some values with terminal ex 29, 140, or even 0
but what i do is not increase by adding new and previous value instead just changing the previous value

this is my code

int value, Evalue, CDEnergy;
 value= InputTerminal.toInt();
    Evalue = Evalue+ value;
    Evalue++;
    CDEnergy = Evalue;

I want the value of CDEnergy to increase, please help

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

Please post your full code.

Without the rest of the code it is not really possible to help you.
You should post code ready for compilation.
Then you should compile it and report compiler errors (if relevant).
Then you should run your code and tell what it should do and does not or what it does and should not do...
This snippet will not compile.
From the snippet I cannot see if your variable scope is good...

Every time this code runs these variables get set to initial values. Is that what you want? If not then keep the declaration at the top of the program so it does not get repeated.

You can ignore my snippet, please help me, give some example about input numeric values who can continue added with the last input value, my problem is when i input 10 then 10 again it’s not 20, but still 10

Did you read post #4 or post #3 ?

Post ALL your code.

this is my code, please help

#define BLYNK_TEMPLATE_ID "TMPLMwuPwwwuLJW"
#define BLYNK_DEVICE_NAME "New Blynk"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
#define APP_DEBUG

#include "BlynkEdgent.h"
#include <TimeLib.h>      /* Program code related to Real Time Clock (RTC). */
#include <WidgetRTC.h>    /* Communication code with Blynk Real Time Clock Widget */
#include <PZEM004Tv30.h>

String InputTerminal;
float Power, Energy, Voltage, Current, Frequency, PFactor;

#if defined(ESP32)
PZEM004Tv30 pzem(Serial2, 16, 17); //   RX & TX on esp32
#else
PZEM004Tv30 pzem(Serial2);
#endif


#define VPIN_TERMINAL                 V20
#define VPIN_CTime                    V27
#define VPIN_CDate                    V28


BLYNK_WRITE(VPIN_TERMINAL)
{ 
  InputTerminal = param.asStr();
}

void setup() {
  Serial.begin(115200);
  rtc.begin(); 
  timer.setInterval(20000L, sendWifi);    // Wi-Fi singal

  BlynkEdgent.begin();
}

BLYNK_CONNECTED() {
if (isFirstConnect) {
  Blynk.syncAll();
//  Blynk.notify("TIMER STARTING!!!!");
  Blynk.logEvent("timer_starting") ;
isFirstConnect = false;
}
//  Blynk.syncVirtual(VPIN_BUTTON_1);
  Blynk.syncVirtual(VPIN_BUTTON_FMudik);
  Blynk.syncVirtual(VPIN_Input_Time); //  Synchronize Time Input Widget when connected
  TimeCheck(); // Initial Time Check
}

void sendWifi() {
  wifisignal = map(WiFi.RSSI(), -105, -40, 0, 100);
}

void loop() {
  // put your main code here, to run repeatedly:
  BlynkEdgent.run();
  sensorpzem();
  
  Blynk.virtualWrite(VPIN_Voltage, Voltage); 
  Blynk.virtualWrite(VPIN_Current, Current); 
  Blynk.virtualWrite(VPIN_Power, Power); 
//  Blynk.virtualWrite(VPIN_Energy, Energy); 
  Blynk.virtualWrite(VPIN_Energy, CDEnergy); 
  Blynk.virtualWrite(VPIN_Frequency, Frequency); 
  Blynk.virtualWrite(VPIN_PFactor, PFactor); 


 int value, Evalue, CDEnergy;
 value = InputTerminal.toInt();
    Evalue = Evalue + value;
    Evalue++;
    CDEnergy = (0.118 + Evalue) - Energy;

  
  Blynk.run();
  delay(800);
}


void sensorpzem()
{
  Voltage = pzem.voltage();
  Current = pzem.current();
  Power = pzem.power();
  Energy = pzem.energy();
  Frequency = pzem.frequency();
  PFactor = pzem.pf();
  

  if (isnan(Voltage))
  {
    Voltage=0;
    Current=0;
    Power=0;
    Frequency=0;
    PFactor=0;
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read voltage\n");
  }
  

  else if (isnan(Current))
  {
    Current=0;
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read Current\n");
  }
 

  else if (isnan(Power))
  {
    Power=0;
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read Power\n");
  }

  else if (isnan(Energy))
  {
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read Energy\n");
  }

  else if (isnan(Frequency))
  {
    Frequency=0;
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read Frequency\n");
  }

  else if (isnan(PFactor))
  {
    PFactor=0;
    Blynk.virtualWrite(VPIN_TERMINAL,"Fail Read Power Factor\n");
  }
}

READ... post #4.

Problem solved.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.