My relay doesn't turn off

#1

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);
}

}

#2

from the serial monitor output it looks like your device disconnects after you turn ON the relay and never connects back. can you share the pic of your circuit.

#3

Hi shramik,

My circuit is similar to the one in the cayenne tutorial, and I have tried many combinations without success. But, if I program the code from arduino it works well for me.
The problem is when I turn off the pump, the message never gets sent. When I turn it on it works well.
Sometimes when I open cayenne the relay goes on by default, if I change to zero, the message is sent well because the pump is disconnected, then I turn it on and it works fine, but once the pump is on, if I try to turn it off, Cayenne is disconnected.

#4

can you join me on http://slack.mydevices.com/