4 Relay Shield, LOW or HIGH

I want to know if driving a relay Control pin HIGH energizes the relay, or if I need to drive it LOW to energize the relay. I have found conflicting information. The Tutorial in Documents indicates that we need to write a HIGH to activate the N.O. relay contact. The Schematic shows the + side of the relay coil connected directly to 5V and the - side of the relay coil is controlled by the Arduino pin. Finally, I asked Chat GPT, and it replied "In the context of the Arduino 4 relay shield, a control pin going LOW typically turns the relay ON. This is a common configuration for relay modules, where the relay is activated when the control pin is set to a LOW state."

And I found that for some 3rd party relay shields HIGH activates the relay.

So I tend to believe that the tutorial is wrong, and that LOW will energize the relay coil. I don't have a shield to actually test it yet. Anyone know for sure.

It depends on the switch configuration of the relay. The ones I used to play with had either 1, 2 or 4 sets of switching contacts. There was the N.O. (normally open) contact, the N.C. (normally closed) contact and the common.

If your relay module requires a HIGH to energise the relay, then the HIGH will link the common to the N.O. contact.

You need to understand that a relay has no control pin. A relay module has a control pin. What you have is a relay module. The relay module contains a relay, and other components. Whether the relay on the relay module is energised when it's control pin is HIGH or LOW depends on the design of that particular relay module, and both designs exist.

So in order to answer your question we need to know what relay module you are using.

Some relay modules contain an opto-isolator. Others do not, but probably both designs will include a MOSFET to handle the high current needed by the relay coil.

The modules that contain opto-isolators generally energise the relay coil when the control pin is LOW. Modules that have no opto-isolator will usually energise the coil when the control pin is HIGH.

I am careful to say "generally" and "usually" because there can always be unusual designs that do not follow these rules.

1 Like

I meant the pin on the Arduino plugged into the 4 relay shield associated with a particular relay on that board. I. E Pins 4, 7, 8, 12 for relay's 1-4. Do I write the code to DigitalWrite those pins HIGH or LOW to energize the associated relay coil?

yes, I fully understand N.O. , N.C., and Common, I need to understand when the Coil energizes?

There's no standard for these relay shields/modules. Unless you have the manufacturer and module number for us to look up OR you have a schematic (or other documentation) that we can look at, trial and error is the best way to determine the input logic level that actuates a relay.

even if i purchase the Arduino brand?

When you add enough power to it. I am assuming you are using a relay module as driving a relay with the Arduino is a great way to fry it.

Without knowing what you have I cannot answer the question. Some will turn on with a high input, others will turn on with a low input and others allow you to select high or low.

4 Relays Shield | Arduino Documentation

For the way I interpreted that page, the relay coil will be energised when the control pin is HIGH. When the coil is energised, the COM pin is connected to the NO pin. When it is not energised, the COM pin is connected to the NC pin.

They give you code to operate the relay:

int relay_1 = 4;
int relay_2 = 7;
int relay_3 = 8;
int relay_4 = 12;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(relay_1, OUTPUT);
  pinMode(relay_2, OUTPUT);
  pinMode(relay_3, OUTPUT);
  pinMode(relay_4, OUTPUT);

}

void loop() {

  digitalWrite(relay_1, HIGH);
  digitalWrite(relay_2, HIGH);
  digitalWrite(relay_3, HIGH);
  digitalWrite(relay_4, HIGH);

  Serial.println("All relays ON");

  delay(1000);

  digitalWrite(relay_1, LOW);
  digitalWrite(relay_2, LOW);
  digitalWrite(relay_3, LOW);
  digitalWrite(relay_4, LOW);

  Serial.println("All relays OFF");

  delay(1000);
}

Per their code and what I can determine from the schematic a logic 1 or high turns the relay on. That causes the NO contact to connect to common and nte NC contact to open from common. Removing power reverses the sequence. Basically it switches the Common contact to the NO when powered and the NC when not powered. There is a LED on the board that lights when the associated relay is energized.

1 Like

Here, from the official schematic, is a copy of a section --


The relay coil is energized when TR1's input is taken HIGH.

1 Like

That's enough ChatGPT.

I remember how last night there was a post with some stuff about there being no standardization and how you basically never can tell about these things - and now it's gone.
(Amazing.)

Many more posts are disappearing.

I recommend you get a copy of the Arduino Cookbook and read it from cover to cover and follow a few tutorials on basic electronics. This is basic stuff you are having a hard time grasping.

Hint a NO (Normally Open) contact closes and the NC (Normally Closed) opens when the relay coil is energized.

According to the sketch in the tutorial section of the documentation at

https://docs.arduino.cc/tutorials/4-relays-shield/4-relay-shield-basics/

each relay is turned ON by writing a HIGH to the appropriate control pin, and is turned OFF by writing a LOW to the control pin:

int relay_1 = 4;
int relay_2 = 7;
int relay_3 = 8;
int relay_4 = 12;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(relay_1, OUTPUT);
  pinMode(relay_2, OUTPUT);
  pinMode(relay_3, OUTPUT);
  pinMode(relay_4, OUTPUT);

}

void loop() {

  digitalWrite(relay_1, HIGH);
  digitalWrite(relay_2, HIGH);
  digitalWrite(relay_3, HIGH);
  digitalWrite(relay_4, HIGH);

  Serial.println("All relays ON");

  delay(1000);

  digitalWrite(relay_1, LOW);
  digitalWrite(relay_2, LOW);
  digitalWrite(relay_3, LOW);
  digitalWrite(relay_4, LOW);

  Serial.println("All relays OFF");

  delay(1000);
}

A common coding "trick" to make code a bit easier to read is to create constants named ON and OFF, with values "HIGH" and "LOW" respectively. The modified sketch is shown below:

int relay_1 = 4;
int relay_2 = 7;
int relay_3 = 8;
int relay_4 = 12;

const bool ON = HIGH;
const bool OFF = LOW;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(relay_1, OUTPUT);
  pinMode(relay_2, OUTPUT);
  pinMode(relay_3, OUTPUT);
  pinMode(relay_4, OUTPUT);

}

void loop() {

  digitalWrite(relay_1, ON");
  digitalWrite(relay_2, ON");
  digitalWrite(relay_3, ON");
  digitalWrite(relay_4, ON");

  Serial.println("All relays ON");

  delay(1000);

  digitalWrite(relay_1, OFF);
  digitalWrite(relay_2, OFF);
  digitalWrite(relay_3, OFF);
  digitalWrite(relay_4, OFF);

  Serial.println("All relays OFF");

  delay(1000);
}
1 Like