Many Channels / Widgets Not initiating Correctly inc Graphs

Using Wemos D1 MQTT, on both the Web (firefox) and android app.

I have many issues that I feel may all be linked to this. Surely this is a bug, it is sooo frustrating that there is not more information available, I have been using Cayenne for around 6 months I had similar issues when I first used Cayenne, and again recently in the past few weeks (Since Arduino updated to MQTT), here is what I have found so far:
Many times you add a new channel to dashboard directly from what is auto detected by cayenne, at this point often you do not get the option to choose any other widget than value widget, at this point you might as well quit and start again - I read somewhere you should always use the first cayenne channel initiated widget to create the graph, then create any other widgets manually, however as option often doesn’t present itself…this is not possible.
This has happened on data types ‘Analog’, ‘Temperature’ and ‘Humidity, maybe more but for me this is what I have experienced.
I have also noticed that when setting data type at arduino to analog and then selecting this as data type on cayenne widget the widget disappears!
Many times when you delete widgets, they remain in the left Navigation tree for the device - impossible to delete!
I also have some widgets that display graphs but the timescales are wrong (Stuck at period in the past) the ‘no data for this period’ seems to be related to the graph updating its current date as the dates displayed are always wrong - it isnt that it can’t display for [This period] it is that it can’t display for some other distant past period.
Some widget also will not allow you to get historical data from the chart pop up either (I assume similar issue)
I have done F5 etc so not an issue with cache etc.
Because I can only get part of maybe 30 widgets working I have not reset up any of my triggers and reluctant to do so at this point. I wanted to expand this out but it is just so frustrating, I have added and then deleted maybe 200 widgets 
Argh…

HI @paulminize,

Think you can post your code?

~Benny

Code below, very new to coding/arduino so have to excuse its ugliness :wink:

//#define CAYENNE_DEBUG // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266.h>
#include <WEMOS_SHT3X.h>

// WiFi network info.
char ssid = “XXXX”;
char wifiPassword = “XXXX”;

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
// char token = “XXXX”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “XXXX”;
char password = “XXXX”;
char clientID = “XXXX”; // Zone 1 - XXXX Zone 2 - XXXX

unsigned long lastMillis = 0;

SHT3X sht30(0x45);

void setup()
{
Serial.begin(9600);
pinMode(D3, INPUT_PULLUP); //Fire
pinMode(A0, INPUT); //Light

Cayenne.begin(username, password, clientID, ssid, wifiPassword);

pinMode(D3, INPUT_PULLUP); //Fire
pinMode(A0, INPUT); //Light
}

void loop()
{
Cayenne.loop();
sht30.get();

   Serial.println(sht30.cTemp);
   Serial.println(sht30.humidity);

int sensorValue2 = digitalRead(D3);
int sensorValue3 = analogRead(A0);

Serial.print("Sensor 2: "); Serial.println(sensorValue2);
Serial.print("Sensor 3: "); Serial.println(sensorValue3);

if ((sensorValue2) == 0) {
Cayenne.virtualWrite(3, 1, “digital_sensor”, “d”);
Serial.println(“System Alert: - Fire Status: FIRE DETECTED”);
Serial.println(“System Action: - Shutting Down All Electrical Outputs / Sprinkler System Activating”);
}
else {
Serial.println(“System Status: - No Faults Detected”);
Cayenne.virtualWrite(3, 0, “digital_sensor”, “d”);
}

if ((sensorValue3) < 700) {
Serial.println(“System Status: - Lights Are Currently On”);
Cayenne.virtualWrite(5, 1, “digital_sensor”, “d”);
}
else {
Serial.println(“System Status: - Lights Are Currently Off”);
Cayenne.virtualWrite(5, 0, “digital_sensor”, “d”);
}

//Publish data every 1 seconds (1000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 1000) {
lastMillis = millis();
//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
Cayenne.virtualWrite(0, lastMillis / 60000);
Cayenne.virtualWrite(1, sht30.cTemp, “temp”, “c”);
Cayenne.virtualWrite(2, sht30.humidity, “rel_hum”, “p”);
Cayenne.virtualWrite(4, 1023 - (sensorValue3));

//Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);

}
}
//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}

Partly solved some issues / workaround

Although still have many widgets that cannot be changed to other types, and even when deleting them, the new replacement suggested by dashboard still cannot be changed - examples -

Zone 2 RCU -

Reservoir Temp Chart can not be changed to any other type of widget.

Channel 1 (Not configured yet) if you try to add - will not allow change of widget.

Cheers

1 Like

I have changed code, just noticed some values were being sent outside the timer, so moved them.

Also changed timer to 10secs not 1sec.

1 Like

Hey slowly improving code at my end, I seem to have everything working as it should do at the minute, although noticed my account password didn’t change again, I received the email and attempted to change it twice, sure I got success messages on both occasions too? Maybe just me?

Cheers

1 Like