Part

Relay module

A logic level on one side, something that has nothing to do with logic on the other.

or see every part
  • 6 pins
  • 3 properties
Drawn live by the editor's own code, at the size you see it.
Reference

Every one of its 6 pins

Pin
Role
What it does
GND
Input or output
Coil return.
IN
Input
Control input; a logic level against half the supply.
VCC
Input or output
Coil supply.
NO
Input or output
Normally open: where COM moves to when energized.
COM
Input or output
The arm.
NC
Input or output
Normally closed: where COM rests when not energized.
This part

What it does

A relay module lets a microcontroller pin switch something that has nothing to do with it. A logic level on IN energizes a coil, the coil pulls a metal arm across, and the arm moves from the normally closed contact to the normally open one; COM is the arm. The board’s 5 volts and whatever the contacts switch share nothing at all. Mokxi’s relay is slow in the way a real one is: 10 milliseconds to pull in and 5 to drop out, with neither contact made while the arm is traveling, so a sketch that toggles it very fast gets nothing, here and on the bench. Below 4 volts on the coil supply it does not pull in whatever IN says. The trigger property is high or low, because most cheap blue relay boards switch when IN is pulled to ground and a sketch written for the other kind runs backwards.

How to use it

How to use a relay module with an Arduino

VCC to 5 V, GND to GND and IN to a digital pin. On the other side, COM is the moving arm: wire it to the supply for the thing you are switching, and wire that thing to NO so it is off until the relay pulls in. Then digitalWrite() the IN pin.

Check which way your board triggers. Most cheap blue relay boards are active low and switch when IN goes to ground; set the part’s trigger property to match the one you have. Never switch a relay faster than it can move: it takes about 10 milliseconds to pull in.

Part pin
Board pin
IN
Pin 13
VCC
5 V
GND
GND
COM and NO
The supply and the load
Arduino Uno: keypad locklive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Reference

The 3 properties you can set

Property
Default
What it means
trigger
high (or low)
high (the default here, matching a bare coil and transistor) or low (the cheap blue boards are nearly all active-low, because their opto-coupler is wired to the rail).
pull_ms
10
10 and 5 ms, the SRD-05VDC datasheet numbers.
release_ms
5
10 and 5 ms, the SRD-05VDC datasheet numbers.
How it is modeled

What is true about the Relay module, here

What is modeled

A relay is slow, and the timing is the part people get wrong: 10 ms to pull in and 5 ms to drop out, matching the datasheet. During that travel neither contact is made (the arm is genuinely in the air, which is "break before make"), so a sketch toggling a relay at a kilohertz does nothing at all here either, exactly as it does nothing on the bench. Below 4 V across VCC/GND the coil cannot pull the arm over at all, whatever IN says, which is the failure everyone meets running a relay off a board's regulator with a motor on the same rail.

Not modeled

Coil current (about 70 mA, which matters for the transistor driving it), contact bounce on the way in, the arc across an inductive load, and the flyback diode, which is already on the module, and is why nothing here needs one added.

The coil is not a coil: VCC/GND are read only to decide whether the supply is above 4 V, so the control side draws nothing at all and there is no inductance, no pull-in current, no hold current and no way to find out that a board's regulator cannot run one. IN is a logic level against half the supply rather than the opto-coupler's LED.

pull_ms and release_ms are exact and identical on every operation, where a real relay's travel time varies with coil voltage and temperature and gets longer as it ages. The contacts are ideal metal with no rating, no resistance drift and no welding.

From Relay module (SRD-05VDC style), in full.

Projects

See the Relay module in a project

Shown here on: Arduino Uno R3

Learn

Where it turns up in a lesson

In a learn article

Wire up the Relay module

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.