Relay module
A logic level on one side, something that has nothing to do with logic on the other.
- 6 pins
- 3 properties
Every one of its 6 pins
COM moves to when energized.COM rests when not energized.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 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.
The 3 properties you can set
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.
See the Relay module in a project
Shown here on: Arduino Uno R3
Where it turns up in a lesson
In a learn article
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Relay module
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.