

If you are not familiar with the PIR motion sensor, you can read the following post: Motion will be detected using a PIR motion sensor. A lamp lights up for 10 seconds every time motion is detected. In this example, we create a motion sensitive lamp. Otherwise, you don’t need to connect it)Įxample: Controlling a Lamp with a Relay Module and PIR Motion Sensor

With the jumper cap on, the VCC and JD-VCC pins are connected. The jumper cap allows you to choose whether the circuit is physically connected to the Arduino circuit or not, and you can choose to have it on or not. Note: notice that the module has a jumper cap connecting the VCC and JD-VCC pins the one shown here is blue, but yours may be a different color.

The JD-VCC pin powers the electromagnet of the relay. The second set of pins consists of GND, VCC, and JD-VCC pins. The set at the right consists of VCC and GND to power up the module, and input 1 ( IN1) and input 2 ( IN2) to control the bottom and top relays, respectively. The low-voltage side has a set of four pins and a set of three pins. If you just want to light up a lamp occasionally, it is better to use a normally-open circuit configuration. NO (Normally Open): the normally open configuration works the other way around: the relay is always open, so the circuit is broken unless you send a signal from the Arduino to close the circuit.NC (Normally Closed): the normally closed configuration is used when you want the relay to be closed by default, meaning the current is flowing unless you send a signal from the Arduino to the relay module to open the circuit and stop the current.The high-voltage side has two connectors, each with three sockets: common (COM), normally closed (NC), and normally open (NO). The six pins on the left side of the relay module connect high voltage, and the pins on the right side connect the component that requires low voltage-the Arduino pins. The following figure shows the relay module pinout. There are other relay modules that are powered using 3.3V, which is ideal for ESP32, ESP8266, and other microcontrollers. This module should be powered with 5V, which is appropriate to use with an Arduino. There are other models with one, four and eight channels. This relay module has two channels (those blue cubes). Introducing the Relay ModuleĪ relay is an electrically operated switch that can be turned on or off, letting the current go through or not, and can be controlled with low voltages, like the 5V provided by the Arduino pins.Ĭontrolling a relay module with the Arduino is as simple as controlling any other output as we’ll see later on.
ARDUINO RELAY MODULES HOW TO
The example we’ll build shows how to control a relay module with an Arduino and a PIR motion sensor.īy the end of this tutorial, you should be able to control any electronics appliances with your Arduino using a relay module. We make a brief introduction to the relay module and build a simple project example with the Arduino. If they don't work, then it could still be an issue from your soldering job, and a multimeter with continuity test would be needed.This article shows how to control mains voltage with the Arduino using a relay module. If they all work, then it is an issue with your soldering job. If the led lights, then the opto side of the coupler and the IN1 work. If it works, the Q1 transistor is good.įinally, apply power to the far side of R1, and ground at the cathode of the IN1 led on the board. Then try power to the JD-VCC point & R2 away from Q1. If it doesn't, the relay is bad OR there is a short. Using two wires, from a 3x AA (4.5v) battery pack, or a 5v supply, connect power and ground directly to the relay's coil pins, bypassing everything else. The easiest thing to do is test each part. The final one is the headers and the traces, especially since you have desoldered and resoldered new headers to the board. The third one is the Relay and Flyback Diode With Q1 as well. The second is the transistor side of the optocoupler. The first is the Opto side of the Optocoupler.
