Add esp8266

add this code at the last:

CAYENNE_IN(1)
   {
   int x = getValue.asInt();
   Serial.println(x);

 digitalWrite(D5, x);

}

it don’t work… Maybe somebody have code just for this; i just need actuate one or two pin

can you share the entire code used for this?

I do like this /*
Cayenne Relay Switch Example

This sketch sample file shows how to set up a Relay Switch with Cayenne.

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. In the Cayenne Dashboard add a new Relay Switch widget.
  2. Select a virtual channel number for the widget.
  3. Set the VIRTUAL_CHANNEL value below to the virtual channel you selected.
  4. Connect your relay switch to a digital pin.
  5. Set the ACTUATOR_PIN value below to the digital pin number you selected.
  6. Set the Cayenne authentication info to match the authentication info from the Dashboard.
  7. Compile and upload this sketch.
  8. Once the Arduino connects to the Dashboard you can use the widget button to turn the relay switch on and off.
    */

#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.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 VIRTUAL_CHANNEL 2
#define ACTUATOR_PIN 4 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.

void setup()
{
Serial.begin(9600);
pinMode(ACTUATOR_PIN, OUTPUT);
Cayenne.begin(username, password, clientID);
}

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

// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN, LOW);
}
}

CAYENNE_IN(1)
{
int x = getValue.asInt();
Serial.println(x);

digitalWrite(D5, x);

}

But i’ve error during compilation : exit status 1
‘D5’ was not declared in this scope

Is strange why is not possible to work like Raspberry ?

you mentioned you are using esp8266, but the header is for ethernet shield.

raspberry pi uses pi agent and is quite advance and handles most of the work, with minimum effort from the user end.
while with arduino, you have to code according to your need with the support cayenne MQTT library.

I just do what cayenne say me… I’m using esp8266 D1 mini

Is not any solutions to do more friendly ?

Can you give me code wich work and after i can change how i want, i’ve just to konw how it work for my application i don’t need more for moment

which device you are using?
which esp8266 pin have you connected the relay?

i’m using windows for go to cayenne and after i select arduino ( who is my esp8266 )

i’ve connect to PIN D5

i mean, which device (hardware) are you using? is it an esp8266 or arduino?

by this, I am assuming you have a nodemcu or wemos esp8266 development board.

/*
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";

#define ACTUATOR_PIN D5

void setup() {
	Serial.begin(9600);
        pinMode(ACTUATOR_PIN, OUTPUT);
	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);
}

CAYENNE_IN(1)
   {
   int x = getValue.asInt();
   Serial.println(x);
 digitalWrite(ACTUATOR_PIN, x);

}

Plusieurs bibliothèque trouvées pour “CayenneArduinoDefines.h”
Utilisé : D:\Users\Tristan\Documents\Arduino\libraries\Cayenne-MQTT-ESP-master
Non utilisé : D:\Users\Tristan\Documents\Arduino\libraries\CayenneMQTT
exit status 1
‘D5’ was not declared in this scope

I think it don’t take good libraries

navigate to this D:\Users\Tristan\Documents\Arduino\libraries and delete this Cayenne-MQTT-ESP-master folder

D:\Users\Tristan\Desktop\mydevices_MQTT_2\mydevices_MQTT_2.ino:56:15: note: in expansion of macro ‘ACTUATOR_PIN’

digitalWrite(ACTUATOR_PIN, x);

           ^

exit status 1
‘D5’ was not declared in this scope

which is the board you have selected in your arduino IDE?

i’m using GENERIC ESP8266 MODULES

follow this guide step by step Adding a New Device using MQTT