Cayenne widget doesn't work


#1

I´m a Beginner with the new mqtt api. I’m using a weemos D1 mini
When i press a widget in the dashboard stucks in changing.

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “";
char wifiPassword[] = "
”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “";
char password[] = "
”;
char clientID = “**”;

#define led_pin 4
#define virtual_led 3

int led;

void setup() {
Serial.begin(9600);
pinMode(led_pin, OUTPUT);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
Cayenne.virtualWrite(0, 10);
digitalWrite(led_pin, HIGH);
Cayenne.virtualWrite(3, HIGH);

}

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

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.

CAYENNE_IN(virtual_led)
{
led = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, virtual_led, led_pin, led);
// Write the value received to the digital pin.
digitalWrite(led_pin, led);
}


#2

make sure that your device is online.


#3

Yes…


#4

can you PM me your email_id.


#5

try this code and give it a try.

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include &lt;CayenneMQTTESP8266.h&gt;

// WiFi network info.
char ssid = “ <em>";
char wifiPassword[] = "</em> ”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “ <strong>";
char password[] = "</strong> ”;
char clientID = “**”;

#define led_pin 4
#define virtual_led 3

int led;

void setup() {
Serial.begin(9600);
pinMode(led_pin, OUTPUT);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
Cayenne.virtualWrite(0, 10);
digitalWrite(led_pin, HIGH);
Cayenne.virtualWrite(3, HIGH);

}

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

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.

CAYENNE_IN(virtual_led)
{
led = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, virtual_led, led_pin, led);
// Write the value received to the digital pin.
digitalWrite(led_pin, led);
}
CAYENNE_OUT_DEFAULT()
{
	Cayenne.virtualWrite(0, millis());
}

#6

Same thing, the channel 0 increases value correctly.


#7

try this code:

/*
This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
1. If you have not already installed the ESP8266 Board Package install it using the instructions here: https://github.com/esp8266/Arduino#installing-with-boards-manager.
2. Select your ESP8266 board from the Tools menu.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "wifiPassword";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";


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

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

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
	// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
	Cayenne.virtualWrite(0, millis());
	// 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("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

#8

Running the code, chanel 0 receiving data.


#9

we are looking into the issue.


#10

@asesmero can you give it a try now by adding a new device?


#11

Now works!, Thanks!!