I need help!

I already did, but I have the relay modules connected in the pins that configure the channel (1 and 2) but physically it does not work.

before we go further with relay connection. open your serial monitor and see if you can read the value of x and y when you turn on the relay button on cayenne dashbaord.

3

al parecer si

sorry, yes that appeared

so now you have a relay button on cayenne dashboard and you are receiving its value. next you have to turn on or off the relay using this value.

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

image

It shows me this error

add this at the top of your code before void setup().

 #define ACTUATOR_PIN 2

the program has already compiled and already loaded it. But physically it still does not work, when I press the button nothing happens. when I press the two buttons on the dasboard (the one on channel 1 and 2) the led of the relay module that is connected on channel 1 gives a small pulse. And channel 2 does nothing.

can you post your entire code.


i am sorry but first you need to learn a bit more about arduino programming.

Yes I so sorry. I am studying electronica and I don´t know to programm. That´s why I decided to use this platform. To do only the electric and electronic part, but now I have problems with programming.

Thank you so much and sorry.

Another question, the platform of cayenne as before worked that was linked practically alone without the need for programming is not available? Or do you have to pay to use it that way?

cayenne MQTT is much more stable and almost similar to previous version. but its better for you to learn a bit more about arduino programming and it will help you alot.
anyways this the entire code which will turn on both the relays.

 // This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";

unsigned long lastMillis = 0;
 
#define ACTUATOR_PIN 2

 #define ACTUATOR_PIN_2 3

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

void loop() {
	Cayenne.loop();

	//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
	if (millis() - lastMillis > 10000) {
		lastMillis = millis();
		//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
		Cayenne.virtualWrite(0, lastMillis);
}
}
CAYENNE_IN(1)
{
int x = getValue.asInt();
Serial.println(x);
digitalWrite(ACTUATOR_PIN, x);
}
CAYENNE_IN(2)
{
int y = getValue.asInt();
Serial.println(y);
digitalWrite(ACTUATOR_PIN_2, x);

}

I thank you very much for all your help and patience. Sorry for so many questions and so much insistence. And indeed, I don´t know to program and I have to learn. Thanks for the links to learn

I already tried the code and it still does not work, it seems that the problem is that it only gives a quick pulse. I know that to make the codes it is necessary to make tests until it works.

Thanks for your help and your good intentions to guide me.

I’m not sure if the code that gives the sketch of “step 1: sketch file” can continue adding relays, because with that code if I work at least one, the problem is to add others due to the code, but I’ll keep trying.
Thank you very much!

try this code

 // This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";

unsigned long lastMillis = 0;
 
#define ACTUATOR_PIN 2

 #define ACTUATOR_PIN_2 3

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

void loop() {
	Cayenne.loop();

	//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
	if (millis() - lastMillis > 10000) {
		lastMillis = millis();
		//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
		Cayenne.virtualWrite(0, lastMillis);
}
}
CAYENNE_IN(1)
{
int x = getValue.asInt();
Serial.println(x);
if (x == 1)
{
digitalWrite(ACTUATOR_PIN,  HIGH);
}
else
{
digitalWrite(ACTUATOR_PIN,  LOW);
}}
CAYENNE_IN(2)
{
int y = getValue.asInt();
Serial.println(y);
if (y == 1)
{
digitalWrite(ACTUATOR_PIN_2,  HIGH);
}
else
{
digitalWrite(ACTUATOR_PIN_2,  LOW);
}
}

it still does not work
the value that appears in the parentheses in the cayenne_in (1) function that “1” is the channel the widget should be on, right? and also it must be the pin of the arduino in this case also would be the 1 truth?

because that’s what I’m doing but it does not work either

you are trying to turn on 2 relays using two separate button on cayenne dashboard?

yes, I have two relay modules which I want to control separately, then I put two buttons, one on channel 1 to control the first module relay and the other on channel 2 to control the second module relay

can you share a photo of your arduino and relay connection.

At the moment I have problems to share the photo, but my connections are as follows:

5v pin Arduino → Vcc pin relay module
GND pin arduino → GND pin relay module
pin 2 arduino → IN pin relay module

the IN pin relay module I am changing it between pin 1 and 2 of the arduino to test with the corresponding buttons because at the moment I do not have a protoboard to share the power for the two modules