Reseting arduino variable of Arduino from Cayenne

Hello guys,

I am trying to figure out how to force a zero value into a double variable from Cayenne, I am builind an electric measurement system and the counter needs to be reseted every month for a new measurement, any idea how to do it? Please find attached my code, it is working fine. I just need to reset the two values when the button “Reset Values” is pressed…

Code.txt (1.2 KB)

Already figured out :grinning:

Example:

int ResetState = 0; // variable for reading the pin status
const int ResetPin = 13; // the number of the Reset pin

void setup()
{
pinMode(ResetPin, INPUT);


}

void loop()
{
Cayenne.run();
ResetState = digitalRead(ResetPin);
if (ResetState == HIGH) {
kwhTotal_Acc = 0;
vlreais_Acc = 0;
}

else {
ltmillis = tmillis;
tmillis = millis();
timems = tmillis - ltmillis;
double Irms = emon1.calcIrms(1480); // Calculate Irms
kwhTotal = (((Irms*127.0)/1000.0) * 1.0/3600.0 * (timems/1000.0));
kwhTotal_Acc = kwhTotal_Acc + kwhTotal;
vlreais = kwhTotal * 0.5773; //Price (Generation, transmission, taxes)
vlreais_Acc = vlreais_Acc + vlreais;
}
}

1 Like

Hehe. Thank you for updating us!

Perhaps you can submit your project to the contest: