Arduino Uno 5V Relay Module: Industrial Load Switching
Professional single-channel relay module integrates SRD-05VDC-SL-C SPDT relay (10A@250VAC/30VDC), PC817 optocoupler (2500Vrms isolation), ULN2803A Darlington driver, and freewheeling diode protection. Active-LOW logic (pin 7 LOW=relay ON) switches 2.5kW loads safely from Arduino GPIO.
3.3-5V VCC, 70mA coil current, 30ms switch time, 100k mechanical operations. NO/NC/COM terminals support motors, lighting, solenoids. Built-in LED indicates relay state.
How It Works
A relay is an electrically operated switch: energising a coil pulls an armature that moves a contact. Its value is isolation — the coil circuit and the contact circuit share no electrical connection, so a 5 V microcontroller can switch a 230 V mains load with a physical air gap between the two.
A relay module adds the parts needed to drive that coil safely. The GPIO cannot supply the 70–100 mA a coil needs, so the board carries a transistor to do the switching, a flyback diode across the coil, and usually an optocoupler for a second layer of isolation.
The flyback diode is not optional. A coil is an inductor, and interrupting its current generates a large reverse voltage spike — hundreds of volts — that destroys the driving transistor. The diode gives that energy a path to circulate harmlessly.
Most hobby relay modules are active LOW: writing LOW to IN energises the relay. This catches people out because a pin defaults to LOW at reset, so the relay clicks on at power-up before the sketch runs.
Components Needed
- Arduino Uno
- 5V Single-Channel Relay Module (SRD-05VDC)
- 14AWG high-current load wires
- External 12-24VDC power supply (loads)
- Male-to-male jumper wires (control)
- 220Ω test LED + 1kHz buzzer
Wiring to the Arduino Uno
Connect IN to D2, VCC to 5 V and GND to ground. The 5 V supply and logic level match standard relay modules directly.
On the load side, COM is the common contact, NO (normally open) connects when energised, and NC (normally closed) disconnects when energised. Wire through NO so the load defaults to off if the board loses power.
Set the output to the inactive level before calling pinMode() in setup. Pins default to LOW, and with an active-LOW module that means the relay energises during boot — which may be unacceptable for whatever is connected.
| Module pin | Arduino Uno pin | Function |
|---|---|---|
| IN | D2 | Control — usually active LOW |
| VCC | 5V | Coil supply (5 V relays are most common) |
| GND | GND | Common ground |
| COM / NO / NC | Load circuit | Isolated switch contacts |
Example Code
Safe relay control with a known-off initial state and minimum dwell time. Upload it with the board set to Arduino Uno and open the Serial Monitor at 9600 baud.
const int RELAY_PIN = 2;
const bool ACTIVE_LOW = true; // most hobby modules
const unsigned long MIN_DWELL_MS = 1000; // protects the contacts from chatter
unsigned long lastSwitch = 0;
bool relayOn = false;
void setRelay(bool on) {
if (millis() - lastSwitch < MIN_DWELL_MS) return; // refuse to chatter
digitalWrite(RELAY_PIN, (on == ACTIVE_LOW) ? LOW : HIGH);
relayOn = on;
lastSwitch = millis();
Serial.println(on ? "relay ON" : "relay OFF");
}
void setup() {
// Drive the pin to the inactive level BEFORE enabling output,
// otherwise the relay clicks on during boot
digitalWrite(RELAY_PIN, ACTIVE_LOW ? HIGH : LOW);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, ACTIVE_LOW ? HIGH : LOW);
Serial.begin(9600);
Serial.println("relay initialised OFF");
}
void loop() {
setRelay(!relayOn);
delay(3000);
}
Applications
A relay module turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:
- Switching mains lighting, heaters and pumps from automation logic
- Motor direction reversal using a double-pole relay
- Isolating high-current DC loads such as car accessories
- Fail-safe cut-offs that open when power is lost
- Interfacing legacy equipment that expects a dry contact closure
Working with the Arduino Uno
The Arduino Uno is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.
The Uno runs at 5 V, so most hobby sensor modules connect directly with no level shifting.
With only 2 KB of SRAM, avoid large buffers and prefer the F() macro for constant strings.
The single hardware UART is shared with the USB connection, so heavy Serial printing competes with uploads.
| Arduino Uno characteristic | Value | Why it matters here |
|---|---|---|
| Logic voltage | 5 V | Matches most hobby modules directly |
| ADC resolution | 10-bit (0–1023) | Sets how finely an analog reading can be resolved |
| Analog inputs | A0–A5 (six channels) | Determines how many analog sensors can share the board |
| PWM outputs | D3, D5, D6, D9, D10 and D11 | Needed for brightness, speed and tone control |
| I²C pins | A4 (SDA) and A5 (SCL) | Fixed by hardware — wiring copied from another board may not match |
| Interrupt pins | D2 and D3 only | Required for counting fast or asynchronous events |
| Serial | a single hardware UART shared with USB | Monitor runs at 9600 baud by default |
Troubleshooting
Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:
- The relay clicks on at power-up — the pin idles LOW and the module is active LOW. Set the level before
pinMode(). - It clicks but the load does not switch — the load is wired to NC instead of NO, or the contacts are undersized for the current.
- The board resets when the relay switches — coil current is dragging the supply down. Power the module separately and tie grounds.
- The relay chatters — the control signal is marginal, or a sensor is oscillating around a threshold. Add hysteresis and a minimum dwell.
- It works on 5 V but not 3.3 V — the coil driver needs a higher logic level; use a transistor or a 3.3 V-rated module.
- Code written for an ESP board gives odd analog values — the Arduino Uno uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
- An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Uno I²C is on A4 (SDA) and A5 (SCL).
Taking It Further on the Arduino Uno
Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Uno specifically:
The Uno’s shield ecosystem is its real advantage. Once the circuit works on a breadboard, a prototyping shield turns it into something permanent that still stacks with a data-logging or Ethernet shield without rewiring.
Logging to an SD card via a shield is the natural next step, since the Uno has no onboard storage and no network. Timestamp each reading with a DS3231 real-time clock so the log survives power cuts with correct times.
Because SRAM is limited to 2 KB, keep logged strings short and write them out immediately rather than buffering. Building a long String in memory is the most common cause of an Uno sketch that runs for hours and then freezes.
Notes and Practical Limits
Mains voltage is lethal. If you are switching 230 V or 110 V, the load wiring must be enclosed, strain-relieved and out of reach, and the relay contacts must be rated for the current with margin. If you are not confident, use a commercial smart plug and control it over the network instead.
Relay contacts wear. Mechanical life is often a million operations but electrical life under load can be as low as 100,000. For loads switched frequently, a solid-state relay or a MOSFET lasts far longer.