Cayenne Dashboard

I have read this but I couldn’t get how to speed up the process. As I added more channels it became slower. Can you please tell me what to add to the code from this article to speed up?

you cant speed up. sorry.

Okay.

This code is continuously sending and receiving data…If I want to send and receive data after some interval like 10 sec, after every 10 sec it should check whether data is updated or not, what should I do for that?

which data are you talking about?

Timestamp of the data is attached. As you can see it is updating the data after 10-15 sec continuously. There is too much delay in the control widget of a button. Like if I press the button for turning on something it takes about 30 - 40 sec to execute. I want to know how can I speed up this process and how can I avoid sending and receiving data continuously for different sensors and input and outputs. Timestamp is attached.

can you share the code used in above.

int i;
double d;
int w;
int t;
int divid;
int emer;
int x;
int xx;


#define VIRTUAL_CHANNEL 2
#define VIRTUAL_CHANNELW 4
#define VIRTUAL_CHANNELT 5
#define VIRTUAL_CHANNELST 7
#define VIRTUAL_CHANNELPST 8
#define VIRTUAL_CHANNELEPC 9
#define VIRTUAL_CHANNELEESOV 10
#define VIRTUAL_CHANNELV1 13
#define VIRTUAL_CHANNELV5 15
#define VIRTUAL_CHANNELV6 16
#define VIRTUAL_CHANNELV7 17
#define VIRTUAL_CHANNELV8 18
#define VIRTUAL_CHANNELV9 19
#define VIRTUAL_CHANNELV10 20
#define VIRTUAL_CHANNELV11 21
#define VIRTUAL_CHANNELV12 22

void setup() {
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  Serial.println("Connected");
             }

void loop()   {
  Cayenne.loop();
}

CAYENNE_IN(1)
{
  CAYENNE_LOG("Got a value: %s", getValue.asStr());
  // You can also use:
  // i = getValue.asInt();
   d = getValue.asDouble();
   divid=d/1.2;
   Serial.println(d);

    Cayenne.virtualWrite(VIRTUAL_CHANNELPST, d, "digital_sensor", "d");
     Cayenne.virtualWrite(VIRTUAL_CHANNEL, divid, "analog_sensor", "null");
}
 CAYENNE_IN(VIRTUAL_CHANNELEPC)

 {
  CAYENNE_LOG("Got an Emergency Value: %s", getValue.asStr());
  emer = getValue.asDouble();
  Serial.println(emer);
  Cayenne.virtualWrite(VIRTUAL_CHANNELEESOV, emer, "digital_sensor", "d");
 }


CAYENNE_IN(3)
{
  x = getValue.asInt();
  Serial.println("got a value in x");
  Serial.println(x);
  Cayenne.virtualWrite(VIRTUAL_CHANNELST, x, "digital_sensor", "d");  
}   
  
CAYENNE_IN(12) //For Valve 1, Turn ON/OFF
{
xx = getValue.asInt();
Cayenne.virtualWrite(VIRTUAL_CHANNELV1, xx, "digital_sensor", "d");
}


CAYENNE_OUT(VIRTUAL_CHANNELV9)

{
   int lk=0;
    Cayenne.virtualWrite(VIRTUAL_CHANNELV9, lk, "digital_sensor", "d");
  
  }
CAYENNE_OUT(VIRTUAL_CHANNELV10)

{
   int ck=1;
    Cayenne.virtualWrite(VIRTUAL_CHANNELV10, ck, "digital_sensor", "d");
  
  }


  CAYENNE_OUT(VIRTUAL_CHANNELV11)

{
   int pk=1;
    Cayenne.virtualWrite(VIRTUAL_CHANNELV11, pk, "digital_sensor", "d");
  
}


  CAYENNE_OUT(VIRTUAL_CHANNELV12)

{
   int au=0;
   Cayenne.virtualWrite(VIRTUAL_CHANNELV12, au, "digital_sensor", "d");
}

 CAYENNE_OUT(VIRTUAL_CHANNELW)
 {
  w=random(101);
  Cayenne.virtualWrite(VIRTUAL_CHANNELW, w, "analog_sensor", "null");
  Serial.println(w);
 }

  CAYENNE_OUT(VIRTUAL_CHANNELT)
 { 
  t=24;
  Cayenne.virtualWrite(VIRTUAL_CHANNELT, t, "temp", "c");
  Serial.println(t);
 }

sorry, but your code is bit confusing. what are you using CAYENNE_IN and CAYENNE_OUT for?

Bro I am controlling tank widget with Button Widget.Like if I turn ON the button, it should start filling the tank from 0 to 100, like +10 every 5 seconds and when I turn off the button it should start decreasing from 100 to 0, -10 every 5 seconds. I am trying this using for loop. but no luck. Can you please help me?
Thanks

before that what does all this above do in your code?

This code is sending and receiving data continuously…I am using multiple channels for inputs and outputs. Code is good. But it is quite slow.

Please answer my question related to Button and Tank widget. A quick help is appreciated. And if you can help in speed up…that would be useful

Thanks

the code is very bad as you are receiving and sending data at same time which might cause the delay in actuator. also i dont know why you are doing this as, you are simply receiving data and sending the same data again to cayenne.

you can send the +10 value to tank widget using cayenneWrite at an interval 5sec using millis() and if condition.

Bro then what should I do to avoid delay?

Can you please write a sample code?

Please tell me efficient way of doing this. I want some inputs and some outputs…Like Pressure gauge for receiving data and Button for Sending like On/Off

Are you there?

there is noting you can do, this is the way cayenne is designed to work with rate limit.

no i cant write code for you. you have write your own code and if you are stuck somewhere i can help you out with it.

start with one thing at a time and then combine your code. add a pressure gauge and see if it working, then try with button. use serial print or #define CAYENNE_DEBUG to check if your code is working as you want.

Bro this is my code for controlling water tank with a On/OFF button:
if (x==1)
{
for (int i=0; i<=100; i++)
{
Cayenne.virtualWrite(VIRTUAL_CHANNELW, i, “analog_sensor”, “null”);
}

}

else
{
for (int e=0; e<=0; e–)
{
Cayenne.virtualWrite(VIRTUAL_CHANNELW, e, “analog_sensor”, “null”);
}
}

I need to incread +10 every 5 seconds and decrease -10 after every 5 seconds. How can I add time factor in it. Please help with the code.
Thanks

try using if loops and millis() at 10 seconds intervals. this should do the what you are trying to achieve.