Problem with the app


#1

Hello,
I have a problem that my project working completely fine when I check it through the web. However, the app doesn’t give me the right reading.For example, if I use the pushbutton that I have setup for reset and start/stop button the reading in some widgets in the app doesn’t change.Here is a video that shows my project on the web


and this is from the app

Cost -SR and Main Power have a strange probelem as you can see

  • Device & model you are using (Ex: Pi 2 Model B or Arduino Uno with W5100 ethernet shield)
    ArduinoMega2560 with W5100 ethernet shield
  • What dashboard are you using? (Web, iOS, Android)
    Web + Android

Pins:
Start/Stop - Virtual 4
Reset - Virtual 3
Input - % - Virtual 0 ( range 0 to 100)
Main Power - Virtual 1 (range 0 to 5)
Cost - SR - Virtual 2 ( Main power * 0.19)
Raw Data - Analog 0 ( range 0 to 1023)

My code
#define CAYENNE_PRINT Serial
#include <CayenneEthernet.h>
#include “CayenneDefines.h”
#define CAYENNE_DEBUG // Uncomment to show debug messages

char token[] = "*****";


float voltage0;
float voltage1;
float voltage2;
int push1=0;
int push2=0;
int save1=0;


#define VOLTAGE0 V0
#define VOLTAGE1 V1
#define VOLTAGE2 V2
#define PUSH1    V3
void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token);
  
}

void loop()
{

Cayenne.run();
int analogValue0 = analogRead(A0);
int analogValue1 = analogRead(A1);
int analogValue2 = analogRead(A2);
  
float a = 20.22176804;
float b = 0.00483398437; // 5V/1024=b  

voltage0 = analogValue0 * a * b;
voltage1 = analogValue0 * (5.0 / 1024.0);
voltage2 = voltage1 * 0.19;
if(push2==1){
Cayenne.virtualWrite(VOLTAGE0,voltage0);
Cayenne.virtualWrite(VOLTAGE1,voltage1);
Cayenne.virtualWrite(VOLTAGE2,voltage2);
delay(500);
}
else {
Cayenne.virtualWrite(VOLTAGE0,0.00);
Cayenne.virtualWrite(VOLTAGE1,0.00);
Cayenne.virtualWrite(VOLTAGE2,0.00);
delay(500);
}

}


//Reset Switch
CAYENNE_IN(V3)
{
int push1 = getValue.asInt(); // Get value as integer
if(push1==1){
Cayenne.virtualWrite(VOLTAGE0,0.0);
Cayenne.virtualWrite(VOLTAGE1,0.0);
Cayenne.virtualWrite(VOLTAGE2,0.0);
delay(2000);
}
}


CAYENNE_IN(V4)
{
push2 = getValue.asInt(); // Get value as integer
}