Hi,
I have a problem getting an acutator to work. I tried to switch the builtin LED of my ESP8266 nodemcu with cayenne_in. I used the example provided here
https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Actuators/LightSwitch/LightSwitch.ino
And modified it to the nodeMCU pinout. I can access the LED during setup() and also in the loop(), but it is not available in online dashboard. The virtualwrite of the time in cayenne_out works.
I am quite confused what is wrong. In the dashboard I cannot add a widget to switch the LED, the option to select my device is greyed out.
This is my code:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#define VIRTUAL_CHANNEL 3
#define ACTUATOR_PIN 2 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Serial.print(“Setup start”);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
pinMode(ACTUATOR_PIN, OUTPUT);// Blink LED if setup finished
for (int i = 0; i < 5; i++)
{
digitalWrite(ACTUATOR_PIN, 0);
delay(100);
digitalWrite(ACTUATOR_PIN, 1);
delay(100);
}
}void loop() {
Cayenne.loop();}
CAYENNE_OUT_DEFAULT()
{
Cayenne.virtualWrite(0, millis() / 1000);
Serial.println(“cayenne out”);
}CAYENNE_IN(VIRTUAL_CHANNEL)
{
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
digitalWrite(ACTUATOR_PIN, value);
}
This is the serial output:
[1077] Connected to WiFi [1077] IP: 192.168.1.195 [1078] Connecting to mqtt.mydevices.com:1883 [1405] Connected [1538] Publish: topic 4, channel 65534, value NodeMCU, subkey , key [1539] Publish: topic 6, channel 65534, value Xtensa32, subkey , key [1553] Publish: topic 7, channel 65534, value 80000000, subkey , key [1627] Publish: topic 5, channel 65534, value v1, subkey , key [4700] Publish: topic 1, channel 0, value 4, subkey , key cayenne out [13771] Connection ok [19912] Publish: topic 1, channel 0, value 19, subkey , key cayenne out [23995] Connection ok
I tried resetting the dashboard and readded the device without any luck.
I would be glad, if you could help me with this.
Kind regards,
Dennis