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

It’s almost impossible to work out what it is that you are trying to achieve from your description and code snippet, but at a guess your issue may be connected with the scope of the variables that you’re using, as you appear to be declaring them locally. I’d guess that you may also have the same variables declared globally?

I’d suggest that you explain the problem differently, add some serial print statements that print the values of your three variables at each stage of the process, and include your full code and serial output in your next post.

Also, the Terminal widget is a very poor way to input numbers. You’d be far better using the Numeric Input widget, but of course you’ll need a Plus subscription to obtain access to that widget.

Pete.

ignore my snippet and about terminal widget, 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

As I said before, it’s probably due to variable scope, but it’s impossible to know without seeing your code.

Pete.

this 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");
  }
}

You should start by reading this…

Also, you are defining (creating a new instance of the variable with a value of zero) the Evalue variable each time this code executes…

So, as I suspected, the issue is one of variable scope, because it seems that Evalue should have been declared globally (near the top of your code) and not locally within the void loop function, or within whatever function you move it to when you sort-out your void loop.

Pete.