Externally powered relay does not work

Hello,
I have an relay, that works great, when I connect it directly to the power of the Arduino.
But when I connect it to an external power supply instead, it does never turn off (it is active low).
I think I did the wiring correctly, please take a look. Any help is greatly appreciated!

EDIT: If I remove the connection between relay in and the pin, the relay turns off. If I connect it directly to the breadboard, it turns on again, which is expected since its active low.

WIRING:

  • black cable: relay vcc «» 5v block +
  • yellow cable: relay gnd «» breadboard
  • purple cable: 5v block - «» breadboard
  • orange cable: arduino gnd «» breadboard
  • blue cable: arduino P5 «» relay in



CODE:

// Define relay pins
#define RELAY1 5  // Arduino Pin D5 (Relay 1)
#define RELAY2 6  // Arduino Pin D6 (Relay 2)
#define RELAY3 7  // Arduino Pin D7 (Relay 3)

// Setup function
void setup() {
  // Initialize relay pins as output
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);

  // Start serial communication at 9600 baud rate
  Serial.begin(9600);

  // Turn off all relays initially
  digitalWrite(RELAY1, HIGH);
  digitalWrite(RELAY2, HIGH);
  digitalWrite(RELAY3, HIGH);

  Serial.println("Relay Controller Ready");
}

// Loop function
void loop() {
  // Wait for a command from Serial Monitor
  if (Serial.available() > 0) {
    char command = Serial.read();  // Read the incoming command

    // Process the command
    switch (command) {
      case '1':  // Turn Relay 1 ON
        digitalWrite(RELAY1, LOW);  // Active low, turn ON
        Serial.println("Relay 1 ON");
        break;
      case '2':  // Turn Relay 1 OFF
        digitalWrite(RELAY1, HIGH);  // Active low, turn OFF
        Serial.println("Relay 1 OFF");
        break;
      case '3':  // Turn Relay 2 ON
        digitalWrite(RELAY2, LOW);  // Active low, turn ON
        Serial.println("Relay 2 ON");
        break;
      case '4':  // Turn Relay 2 OFF
        digitalWrite(RELAY2, HIGH);  // Active low, turn OFF
        Serial.println("Relay 2 OFF");
        break;
      case '5':  // Turn Relay 3 ON
        digitalWrite(RELAY3, LOW);  // Active low, turn ON
        Serial.println("Relay 3 ON");
        break;
      case '6':  // Turn Relay 3 OFF
        digitalWrite(RELAY3, HIGH);  // Active low, turn OFF
        Serial.println("Relay 3 OFF");
        break;
      default:
        Serial.println("Invalid Command");
        break;
    }
  }
}
R1_ON = b"1"
R1_OFF = b"2"

arduino = serial.Serial('/dev/ttyACM0', 9600)
arduino.write(R1_ON)
arduino.write(R1_OFF)

The first thing to check is how many milliamps the coil requires at what voltage to pull in. A 9V PP3 battery is designed to deliver a low amount of current for a long time. It is not designed to deliver high amounts of current for any amount of time.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.