Hi all,
I’m quite new to arduino/Cayenne.
I’m using a NodeMCU ESP8266 with Cayenne - The board has a button on it and a relay connected to it as well.
We have V3 on Cayenne - connected to the relay so each time the virtual and real button is pressed, the relay is triggered. (This is used to control my garage door).
Although, when I power cycle the device - and it connects to the Cayenne service - the virtual button is triggered.
"[1752] Connected to WiFi
[1752] My IP: 192.168.0.131
[5001] Connecting to arduino.mydevices.com:8442
[5779] Connecting to arduino.mydevices.com:8442
[11420] Connecting to arduino.mydevices.com:8442
[12315] Ready (ping: 193ms).
Cayenne Button Pressed (Serial output for troubleshooting) —> I didn’t press this.
And when I removed the button entirely from Cayenne - It stopped triggering upon bootup.
> #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
> #include <ESP8266WiFi.h>
> #include "CayenneDefines.h"
> #include "BlynkSimpleEsp8266.h"
> #include "CayenneWiFiClient.h"
> #include <Wire.h>
> #include <DHT.h>
> #define VIRTUAL_PIN V3
> #define RELAY D1
> #define BUTTON D2
> // Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
> char token[] = "";
> // Your network name and password.
> char ssid[] = "";
> char password[] = "";
> long rssi;
> IPAddress ip;
> void setup() {
> // digitalWrite(RELAY, HIGH); // Keep relay off while device turning on
> Serial.begin(230400);
> Cayenne.begin(token, ssid, password);
> pinMode(BUTTON, INPUT);
> }
> void loop() {
> Cayenne.run();
> int buttonState = digitalRead(BUTTON);
> if (buttonState == HIGH) {
> pinMode(RELAY, OUTPUT);
> digitalWrite(RELAY, LOW);
> Serial.println("Button Pressed"); // Test if button works
> } else {
> digitalWrite(RELAY, HIGH);
> }
> }
> CAYENNE_IN(V3) {
> pinMode(RELAY, OUTPUT);
> Serial.println("Cayanne button pressed");
> unsigned char i, j ;// define variables
> for (i = 0; i <2; i++) {
> digitalWrite(RELAY, LOW);
> delay(150);
> digitalWrite(RELAY,HIGH);
> }
> }