LED not lightning up

I can get values of button on serial port as i triggers it but i can’t get the LED to light up
Below is my code:
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

#define vp1 1
#define vp2 2

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

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxx”;
char password = “xxx”;
char clientID = “xxx”;
unsigned long lastMillis = 0;

void setup() {
pinMode(D2, OUTPUT);

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


void loop() {
if (millis() - lastMillis > 3000)
lastMillis = millis();

// 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.
// 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);



int currentValue = getValue.asInt();
if (currentValue == 1) {
digitalWrite(D2, HIGH);
else {
digitalWrite(D2, LOW);


int currentValue = getValue.asInt();
if (currentValue == 1) {
digitalWrite(D0, HIGH);
else {
digitalWrite(D0, LOW);

This is what i saw from Serial Port
[2048] Connected to WiFi
[2048] IP:
[2048] Connecting to mqtt.mydevices.com:1883
[2934] Connected
[7420] Channel 65534, value 1
[10640] Channel 65534, value 0

As for the setup, i just link a wire from D2 to positive side of LED bulb while the other goes to ground

Pls help, Thanks

from the serial monitor output, it looks like you have added button on the cayenne dashboard to channel number: 65534

Yes i do add a button to control the on and off of led but i don’t get what u mean by ‘added button on the cayenne dashboard to channel number: 65534’
Sorry for the problem cause i’m really a beginner

This output shows that the channel is 65534. Thus representing that the button is added on channel 65534. You might want to check the button setting by clicking on the clog wheel on the wifget.

Even if i change the channel from D0 to D2 it still couldn’t light up the led
Do u mind if i straight pm u?

Can toy just put the number 1 or 2

ok it works
thank u very much!!!

1 Like

Great to hear that.