A 5V relay is an electromechanical switch that uses an electromagnetic coil to open or close contacts. It allows a low voltage signal (5V) to control high voltage or high current circuits, making it an essential component in automation, home appliances, and industrial control systems.
The 5V relay module typically has the following pins:
Pin Name | Description |
---|---|
VCC | Connect to 5V DC power supply to energize the relay coil. |
GND | Ground connection for the relay module. |
IN | Control signal input (logic HIGH to activate the relay, logic LOW to deactivate). |
COM | Common terminal for the relay switch. |
NO | Normally Open terminal; connected to COM when the relay is activated. |
NC | Normally Closed terminal; connected to COM when the relay is deactivated. |
Below is an example of how to control a 5V relay using an Arduino UNO to turn a light bulb ON and OFF.
// Define the relay control pin
const int relayPin = 7;
void setup() {
// Set the relay pin as an output
pinMode(relayPin, OUTPUT);
// Ensure the relay is OFF at startup
digitalWrite(relayPin, LOW);
}
void loop() {
// Turn the relay ON (light bulb ON)
digitalWrite(relayPin, HIGH);
delay(5000); // Keep the light ON for 5 seconds
// Turn the relay OFF (light bulb OFF)
digitalWrite(relayPin, LOW);
delay(5000); // Keep the light OFF for 5 seconds
}
Relay Not Activating:
Relay Stuck in One State:
Load Not Turning ON/OFF:
Microcontroller Resetting When Relay Activates:
Q: Can I use a 5V relay with a 3.3V microcontroller?
A: Yes, but you may need a transistor or MOSFET to amplify the control signal to 5V.
Q: Is it safe to use a 5V relay for AC loads?
A: Yes, as long as the load's voltage and current are within the relay's rated specifications.
Q: Why is a clicking sound coming from the relay?
A: The clicking sound is normal and indicates the relay is switching states. If it clicks continuously, check for a faulty control signal.
Q: Can I control multiple relays with one microcontroller?
A: Yes, as long as each relay has its own control pin and the microcontroller can handle the combined current draw.