ESP8266-12E, Arduino, Relay switch, Light on Dashboard


#1

it´s my second project.

It was just an Idea to make it. It was tricky but its run very well.

Hope, this will help some Newbies with a ESP and Cayenne, yeah its sometimes tricky !

With this Sketch, you can switch just an Led on/off and a 2 way Relay for some electrics on the Cayenne Dashboard.

The Cayenne_IN function works well !

Yoel have to configure widgets and the Channels on Cayenne Dashboard !

Hi Community,
20171212_090329|666x500

Arduino Sketch

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

char ssid[] = "***";
char wifiPassword[] = "***";

char username[] = "*****";
char password[] = "*****";
char clientID[] = "*****";

void setup() {
  // put your setup code here, to run once:
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  pinMode(5, OUTPUT);
  digitalWrite(5, LOW);
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  Cayenne.loop();

}
CAYENNE_IN(6)
{
  int currentValue = getValue.asInt();
  if (currentValue == 1)
  {
    //do whatever you want when you turn on the button on cayenne dashboard
    digitalWrite(2, HIGH);
  }
  else
  {
    //do whatever you want when you turn off the button on cayenne dashboard
    digitalWrite(2, LOW);
  }
}
CAYENNE_IN(7)
{
  int currentValue = getValue.asInt();
  if (currentValue == 1)
  {
    //do whatever you want when you turn on the button on cayenne dashboard
    digitalWrite(5, HIGH);
  }
  else
  {
    //do whatever you want when you turn off the button on cayenne dashboard
    digitalWrite(5, LOW);
  }
}
CAYENNE_IN(8)
{
  int currentValue = getValue.asInt();
  if (currentValue == 1)
  {
    //do whatever you want when you turn on the button on cayenne dashboard
    digitalWrite(4, LOW);
  }
  else
  {
    //do whatever you want when you turn off the button on cayenne dashboard
    digitalWrite(4, HIGH);
  }
}

#2

Nice project, thanks for sharing!


#3

Great project!


#4

very nice @Sven, very nice! your sketch showed me some nuances in use