Hi team cayenne.
I have a problem with my relay when I connected a water pump.
The fact is that when I use the relay with normal arduino it turns off and on correctly, but when I want to turn it off with cayenne the board disconnects and the pump does not turn off. However, if I connect an LED to the relay it works well with cayenne, it only happens when I connect the pump.
My component are:
Arduino uno
Ethernet shield w5100
Pump halija DC3- 5v
The error message when i put the pin in 0:
[0] MAC: xxx
[7519] IP: xxx
[7520] Connecting to mqtt.mydevices.com:1883
[7843] Connected
[11456] CAYENNE_IN_DEFAULT(1) - xGv0HJMJwGM7yoF, 1
[106452] Disconnected
[106454] Connecting to mqtt.mydevices.com:1883
[108284] Network connect failed
[111111] Network connect failed
[113937] Network connect failed
The code is:
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xx”;
char password = “xx”;
char clientID = “xx”;
#define VIRTUAL_CHANNEL 1
#define ACTUATOR_PIN 7
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)
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString());
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 1) {
digitalWrite(ACTUATOR_PIN, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN, LOW);
}
}