Hey there. This is the exact relay I'm using. And my setup for it is shown below. The code is irrelevant since it works on the arduino side and my question is related to a possible broken/welded conneciton in the relay.
It worked fine for a time but after about 10-15 mins, it started to work in an always ON state. the LED's on relay showed correctly according to the code, I also could hear the tick when the digital pin triggered the relay too. I'm not so new to electronics but certainly not an expert. It seems to me that the trigger works properly but something might have welded/melted inside so that the electricity always flows through.
Bear in mind that I tried to disconnect arduino and 5V power completely from the relay and it still worked. The power relayed through it like there's no sort of control. I am of course using the NC (Normally Closed) way but no go. Also, switching over to NO way seems to stop the flow of electricity but then, the switch does not do anything.
When nothing makes sense, I'm almost sure that there's something awfully wrong
The relay is fairly cheap, I ordered new ones with spares too but still would like to know if I'm not aware of something.
The motor I use the relay for draws 0.640A at max (640mA).
So what do you think? Can the relay be burnt? I see no sign of burning/darkening but of course that may not be related at all.
For curiosity, My whole project is something like this;
#include <neotimer.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <NewPing.h>
#define SONAR_NUM 2 // Number or sensors.
#define MAX_DISTANCE 90// Max distance in cm.
#define PING_INTERVAL 33 // Milliseconds between pings.
#define ledUp 12
#define ledDown 7
unsigned long pingTimer[SONAR_NUM]; // When each pings.
unsigned int cm[SONAR_NUM]; // Store ping distances.
uint8_t currentSensor = 0; // Which sensor is active.
uint8_t lastSensor = 0; // Which sensor is active.
int value1;
int value2;
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified module
Neotimer thetimer = Neotimer(1000);
NewPing sonar[SONAR_NUM] = { // Sensor object array.
NewPing(9, 10, MAX_DISTANCE),
NewPing(11, 8, MAX_DISTANCE),
};
void setup() {
pinMode(ledUp, OUTPUT);
pinMode(ledDown, OUTPUT);
digitalWrite(ledUp, HIGH);
digitalWrite(ledDown, HIGH);
Serial.begin(115200);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(LOW);
lcd.begin(16, 2);
lcd.clear();
pingTimer[0] = millis() + 75; // First ping start in ms.
thetimer.start();
for (uint8_t i = 1; i < SONAR_NUM; i++)
pingTimer[i] = pingTimer[i - 1] + PING_INTERVAL;
}
void loop() {
for (uint8_t i = 0; i < SONAR_NUM; i++) {
if (millis() >= pingTimer[i]) {
pingTimer[i] += PING_INTERVAL * SONAR_NUM;
if (i == 0 && currentSensor == SONAR_NUM - 1)
sonar[currentSensor].timer_stop();
currentSensor = i;
cm[currentSensor] = 0;
sonar[currentSensor].ping_timer(echoCheck);
}
}
if(thetimer.repeat(300)){
lcd.setCursor(0,1);
lcd.print("Reset");
value1 = 0;
value2 = 0;
}
lcd.setCursor(0,0);
lcd.print("Working");
lcd.setCursor(0,1);
lcd.print("No Action");
if(cm[0] > 0 || cm[1] > 0)
{
Serial.print("0");
Serial.print("=");
Serial.print(cm[0]);
Serial.print("cm ");
Serial.print("1");
Serial.print("=");
Serial.print(cm[1]);
Serial.print("cm ");
Serial.println();
}
if (cm[0] > 10){
value1 = 1;
thetimer.reset();
delay(50);
}
if (cm[1] > 10 && value1 == 1){
value1 = 0;
goUp();
digitalWrite(ledUp, LOW);
delay(400);
digitalWrite(ledUp, HIGH);
lcd.clear();
value1 = 0;
value2 = 0;
}
//set value 2 true
if (cm[1] > 10){
value2 = 1;
thetimer.reset();
delay(50);
}
if (cm[0] > 10 && value2 == 1){
value2 = 0;
goDown();
digitalWrite(ledDown, LOW);
delay(400);
digitalWrite(ledDown, HIGH);
lcd.clear();
value1 = 0;
value2 = 0;
}
}
void goUp()
{
Serial.println("MovingUpStarted");
lcd.setCursor(0,1);
lcd.print("Go Up Trigger");
value1 = 0;
value2 = 0;
}
void goDown()
{
Serial.println("MovingDownStarted");
lcd.setCursor(0,1);
lcd.print("Go Down Trigger");
value1 = 0;
value2 = 0;
}
void echoCheck() { // If ping echo, set distance to array.
if (sonar[currentSensor].check_timer())
cm[currentSensor] = sonar[currentSensor].ping_result / US_ROUNDTRIP_CM;
}