Power Intelligence: The Arduino Nano Relay Module Manual
The Relay Module is the definitive bridge between low-power microcontrollers and high-power appliances. Because the Arduino Nano operates at 5V and can only provide a few milliamps per pin, it cannot directly power a light bulb or a heater. A relay acts as an electrically operated switch, using a small current from the Nano to move a mechanical contact that completes a much larger circuit, effectively allowing a tiny chip to control the world's power grid.
How it Works: The Solenoid and Armature
Inside the blue plastic cube of a standard SRD-05VDC relay is an electromagnetic coil (solenoid). When the Nano sends a signal, current flows through the coil, creating a magnetic field. This field pulls a metal lever (armature) which physically snaps the high-voltage contacts together. When the power is removed, a spring pulls the contacts apart, breaking the circuit.
Wiring the Relay to Arduino Nano
Relay modules usually have two sides: the Input Side (Low Voltage) connected to the Nano, and the Output Side (High Voltage) connected to the appliance. Most modules feature an Optoisolator (a small 4-pin chip) that uses light to transfer the signal, providing a physical air gap that protects the Nano from high-voltage spikes.
| Module Pin | Function | Arduino Nano Pin |
|---|---|---|
| VCC | Power Supply (5V) | 5V |
| GND | Ground | GND |
| IN | Control Signal | Digital Pin 3 |
| COM (Output) | Common Terminal | Power Source Input |
| NO (Output) | Normally Open | Load / Appliance Input |
| NC (Output) | Normally Closed | Optional Fail-safe Input |
Programming: Toggling High-Power Loads
Programming a relay is identical to blinking an LED. However, most relay modules are Active LOW, meaning the relay turns ON when the pin is set to LOW and OFF when the pin is HIGH. This is a safety feature designed to keep the relay off if the Nano loses power.
// Define Pin Constant
const int relayPin = 3;
void setup() {
// Initialize the pin as an output
pinMode(relayPin, OUTPUT);
// Ensure relay starts in OFF state (Active LOW logic)
digitalWrite(relayPin, HIGH);
}
void loop() {
// Turn the Relay ON (Connects COM to NO)
digitalWrite(relayPin, LOW);
delay(5000); // Keep appliance on for 5 seconds
// Turn the Relay OFF (Connects COM to NC)
digitalWrite(relayPin, HIGH);
delay(5000); // Keep appliance off for 5 seconds
}
Real-World Power Scenarios
The Arduino Nano’s small size makes it the definitive brain for hidden or integrated power control systems:
- Smart Light Switches: Fitting a Nano and a relay behind a standard wall plate to allow for Wi-Fi or Bluetooth controlled home lighting.
- Automated Irrigation: Using the Nano to trigger a 12V or 24V water solenoid valve based on soil moisture sensor data.
- Temperature Control: Activating a high-wattage space heater or a cooling fan when an attached thermistor detects a specific threshold.
- Industrial Gateways: Using a multi-channel relay board to sequence the power-up of heavy machinery to prevent electrical surges.
Common Pitfalls & AC Safety
- Mains Voltage Warning: Working with 110V/220V AC is potentially lethal. Always ensure the power is disconnected while wiring, and use a properly insulated enclosure to prevent accidental contact.
- The 'Click' but No Power: If you hear the relay click but the light doesn't turn on, check your COM (Common) wiring. The relay is just a switch; it does not provide power to the load on its own.
- Back EMF Spikes: When a relay coil turns off, it creates a voltage spike. Ensure your module has a Flyback Diode (standard on most modules) to prevent these spikes from resetting your Nano.
- Current Limits: Standard blue relays are rated for 10A. If you are controlling a heavy motor or an air conditioner that draws more than 10A, the contacts may weld shut. Use a Solid State Relay (SSR) or a larger contactor for these loads.
Final Summary
Interfacing a Relay Module with the Arduino Nano is a fundamental requirement for the Internet of Things (IoT). By mastering the isolation between low-power logic and high-power circuits, you bridge the gap between digital code and the physical appliances of the real world, enabling your projects to control everything from a single LED to a full industrial assembly line.