electromechanical-relay-demo

Introduction

This tutorial demonstrates the operation of an electromechanical relay using an Arduino, showcasing a key component in automation and control systems. Electromechanical relays are switches that use an electromagnet to mechanically open or close a circuit, allowing low-power signals (like those from an Arduino) to control high-power devices. In this experiment, you’ll build a simple setup to activate a relay, observe its switching action, and explore its capabilities. This project is perfect for beginners and educators aiming to understand relay mechanics and their role in electromechanical systems.

Relays provide electrical isolation and can handle significant power loads, making them versatile for controlling lights, motors, or appliances. By the end of this tutorial, you’ll have a working demonstration of a relay in action, complete with Arduino control and practical insights.

Components Required

To set up your electromechanical relay demonstration, you’ll need the following components:

Schematic

The schematic details how to connect the relay module to the Arduino and a load for demonstration:

Basic connection overview: - Connect the relay module’s VCC to Arduino 5V and GND to Arduino GND. - Wire the relay’s signal pin (IN) to an Arduino digital pin (e.g., D8). - Attach the load (e.g., a 9V LED with a current-limiting resistor) to the relay’s normally open (NO) and common (COM) terminals. - Connect the load’s power supply (e.g., 9V battery) in series with the relay’s NO-COM circuit.

Note: Ensure the relay’s coil voltage matches the Arduino’s 5V logic. For loads exceeding the relay’s rating (e.g., 10A at 250V AC), use a separate power source and exercise caution.

Steps

Follow these steps to build and test your electromechanical relay demonstration:

  1. Assemble the Circuit: Connect the relay module’s VCC to 5V, GND to GND, and IN to Arduino D8.
  2. Wire the Load: Attach a load (e.g., 9V LED with a 220Ω resistor) to the relay’s NO and COM terminals, then connect its power supply.
  3. Power the Setup: Connect the Arduino to a USB power source and the load’s power supply (e.g., 9V battery), keeping it off until tested.
  4. Upload the Code: Load the Arduino sketch (see "Code Example" below) to control the relay.
  5. Test the Relay: Run the code to switch the relay on and off, listening for the click and observing the load’s response (e.g., LED lights up).
  6. Enhance (Optional): Add a buzzer or LED directly to the Arduino to signal relay state changes for a clearer demo.

Code Example

Here’s an Arduino sketch to demonstrate an electromechanical relay by toggling it on and off:

                
// Define relay control pin
const int RELAY_PIN = 8;  // Digital pin

void setup() {
    pinMode(RELAY_PIN, OUTPUT);
    Serial.begin(9600);  // For debugging
    digitalWrite(RELAY_PIN, LOW);  // Start with relay off
}

void toggleRelay(bool state) {
    if (state) {
        Serial.println("Relay ON - Load activated");
        digitalWrite(RELAY_PIN, HIGH);  // Activate relay
    } else {
        Serial.println("Relay OFF - Load deactivated");
        digitalWrite(RELAY_PIN, LOW);   // Deactivate relay
    }
}

void loop() {
    toggleRelay(true);   // Turn on
    delay(2000);         // Wait 2 seconds
    toggleRelay(false);  // Turn off
    delay(2000);         // Wait 2 seconds
}
                
            

This code switches the relay every 2 seconds, activating and deactivating the load (e.g., an LED). You’ll hear the relay click and see the load respond. Adjust `delay()` for different timing.

Applications

Demonstrating an electromechanical relay has practical applications in various scenarios, including:

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!